Skip to content

Commit

Permalink
some change
Browse files Browse the repository at this point in the history
  • Loading branch information
Summerlve committed Mar 26, 2016
1 parent eec946a commit 3b6598a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,17 @@ cd $JS-OPTIONAL/test <br />
mocha test.js <br />

### Common use cases
``` javascript
let version = Optional.ofNullable("3.0.0").orElse("defalut");

version = Optional.ofNullable({version: "3.0.0"})
.flatMap(value => Optional.ofNullable(value.version))
.map(_ => _)
.orElse("UNKNOWN");

let isUSB3 = Optional.ofNullable("2.0")
.filter(_ => _ === "3.0")
.isPresent();

assert.equal(false, isUSB3);
```

0 comments on commit 3b6598a

Please sign in to comment.