Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xnimorz/maybe
Maybe monad with full types support!
https://github.com/xnimorz/maybe
Last synced: about 1 month ago
JSON representation
Maybe monad with full types support!
- Host: GitHub
- URL: https://github.com/xnimorz/maybe
- Owner: xnimorz
- License: mit
- Created: 2023-11-26T16:30:14.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-27T23:42:34.000Z (about 1 year ago)
- Last Synced: 2024-11-17T08:49:27.126Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 75.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @duorun/Maybe
TypeScript implementation maybe monad.
1. Easy-to-use
2. Small (267 Bytes)!
3. Typed API## Install:
```shell
npm i @duorun/maybe --save
```## Playground:
Sandbox: https://codesandbox.io/p/sandbox/nifty-lake-5wpq2y
## Usages
Value is defined:
```js
just("bar"); // Maybe
```Value is empty:
```js
none(); // Maybe
```Note: null / undefeind can be valid data:
```js
just(null); // Maybe
```Check if value is defined:
```js
import { isNone } from "@duorun/maybe";function test(maybe: Maybe) {
if (isNone(maybe)) {
// maybe is None
} else {
// maybe is just
maybe.value; // string
}
}
```