26 lines
474 B
Markdown
26 lines
474 B
Markdown
# kojima
|
|
a small functional/monad library
|
|
|
|
# Usage
|
|
## Example
|
|
```js
|
|
import { Option, Some, None, Result, Ok, Err } from 'kojima'
|
|
|
|
const maybe = Option.of('thing')
|
|
maybe.isSome() // true
|
|
const isnt = maybe.chain(None).map(_x => 'other') // None
|
|
isnt.isSome() // false
|
|
|
|
const result = Result.of('3:41am')
|
|
result.isOk() // true
|
|
|
|
result.bind(() => Err(new Error(-Infinity)))
|
|
.map(_x => '4:10am')
|
|
.bind(Ok)
|
|
|
|
result.isErr() // true
|
|
|
|
// crimes!
|
|
None == None() // true
|
|
```
|
|
|