Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akarachen/sakiko
Some monad implement with js.
https://github.com/akarachen/sakiko
Last synced: 5 days ago
JSON representation
Some monad implement with js.
- Host: GitHub
- URL: https://github.com/akarachen/sakiko
- Owner: AkaraChen
- Created: 2024-05-14T07:42:16.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-09-16T07:09:48.000Z (about 2 months ago)
- Last Synced: 2024-10-24T03:59:30.605Z (14 days ago)
- Language: TypeScript
- Homepage: https://sakiko.vercel.app
- Size: 128 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sakiko
> Deprecated, use [Effect-ts](https://effect.website) instead.
Some monad implement with js.
[Document](https://sakiko.vercel.app)
## Option
Use to handle null or undefined value.
```js
import { Option } from 'sakiko'const value = Option.some(1)
.map(v => v + 1)
.map(v => v * 2)
.unwrapOr(0)
```## Result
Use to handle error.
```js
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.
```js
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)
```