Skip to content

Commit

Permalink
Merge pull request #16 from bromne/develop
Browse files Browse the repository at this point in the history
v2.0.0
  • Loading branch information
bromne authored Jan 4, 2019
2 parents afe944a + 4351102 commit 94a5fd6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ npm install --save typescript-optional

```ts
// import Optional type from this module
import Optional from 'typescript-optional';
import { Optional } from "typescript-optional";
```

### creating `Optional<T>` objects
Expand Down
8 changes: 4 additions & 4 deletions src/optional.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,21 @@ describe("Optional", () => {

describe("#isPresent", () => {
it("should return true if it is present", () => {
assert.strictEqual(sutPresent.isPresent, true);
assert.strictEqual(sutPresent.isPresent(), true);
});

it("should return false if it is not present", () => {
assert.strictEqual(sutEmpty.isPresent, false);
assert.strictEqual(sutEmpty.isPresent(), false);
});
});

describe("#isEmpty", () => {
it("should return false if it is present", () => {
assert.strictEqual(sutPresent.isEmpty, false);
assert.strictEqual(sutPresent.isEmpty(), false);
});

it("should return true if it is not present", () => {
assert.strictEqual(sutEmpty.isEmpty, true);
assert.strictEqual(sutEmpty.isEmpty(), true);
});
});

Expand Down
16 changes: 8 additions & 8 deletions src/optional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ import { Cases, Option } from "./types";
*/
export abstract class Optional<T> {
/**
* Represents whether this is present or not.
* Returns whether this is present or not.
*
* If a payload is present, be `true` , otherwise be `false`.
*/
abstract get isPresent(): boolean;
abstract isPresent(): boolean;

/**
* Represents whether this is empty or not.
* Returns whether this is empty or not.
*
* If this is empty, be `true`, otherwise be `false`.
* This method is negation of `Optional.isPresent`.
* This method is negation of `Optional#isPresent`.
*/
get isEmpty(): boolean {
return !this.isPresent;
isEmpty(): boolean {
return !this.isPresent();
}

/**
Expand Down Expand Up @@ -219,7 +219,7 @@ export abstract class Optional<T> {
class PresentOptional<T> extends Optional<T> {
payload: T;

get isPresent(): boolean {
isPresent(): boolean {
return true;
}

Expand Down Expand Up @@ -291,7 +291,7 @@ class PresentOptional<T> extends Optional<T> {
}

class EmptyOptional<T> extends Optional<T> {
get isPresent(): boolean {
isPresent(): boolean {
return false;
}

Expand Down

0 comments on commit 94a5fd6

Please sign in to comment.