1.5.0 • Published 10 months ago

sakiko v1.5.0

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

sakiko

Deprecated, use Effect-ts instead.

Some monad implement with js.

Document

Option

Use to handle null or undefined value.

import { Option } from 'sakiko'

const value = Option.some(1)
    .map(v => v + 1)
    .map(v => v * 2)
    .unwrapOr(0)

Result

Use to handle error.

import { Result } from 'sakiko'

const value = Result.ok(1)
    .isOkAnd(v => v >= 0)
    .map(v => v + 1)
    .unwrapOr(0)

Future

A wrapper of Promise. Provide a powerful way to handle async code.

import { Future } from 'sakiko'

const future = Future.from(async () => {
    // do something async
})

// at any time
future.isOk() // true if the future is resolved

// Or you can map to `Result`
const result = await future.result()
result.unwrapOr(0)
1.5.0

10 months ago

1.2.0

1 year ago

1.1.0

1 year ago

1.4.0

11 months ago

1.3.0

11 months ago

1.0.0

1 year ago