a lightweight algebraic structure library
src | ||
tests | ||
.gitignore | ||
jsconfig.json | ||
package-lock.json | ||
package.json | ||
README.md |
kojima
a small functional/monad library
Usage
Example
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.chain(() => Err(new Error(-Infinity)))
.map(_x => '4:10am')
.chain(Ok)
result.isErr() // true
// crimes!
None == None() // true