Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vitorluizc/maybe
🌯 The prettiest TypeScript implementation of Maybe monad.
https://github.com/vitorluizc/maybe
ava bili fp functional functional-programming maybe maybe-monad maybe-type optional optional-type optional-typing type-safe type-safety typescript
Last synced: 3 months ago
JSON representation
🌯 The prettiest TypeScript implementation of Maybe monad.
- Host: GitHub
- URL: https://github.com/vitorluizc/maybe
- Owner: VitorLuizC
- License: mit
- Created: 2019-02-11T03:51:03.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-09T20:13:56.000Z (about 3 years ago)
- Last Synced: 2024-11-03T08:06:32.467Z (3 months ago)
- Topics: ava, bili, fp, functional, functional-programming, maybe, maybe-monad, maybe-type, optional, optional-type, optional-typing, type-safe, type-safety, typescript
- Language: TypeScript
- Homepage: https://github.com/VitorLuizC/maybe/tree/master/docs
- Size: 242 KB
- Stars: 19
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `@bitty/maybe`
[![Library minified size](https://badgen.net/bundlephobia/min/@bitty/maybe)](https://bundlephobia.com/result?p=@bitty/maybe)
[![Library minified + gzipped size](https://badgen.net/bundlephobia/minzip/@bitty/maybe)](https://bundlephobia.com/result?p=@bitty/maybe)## Installation
This library is published in the NPM registry and can be installed using any compatible package manager.
```sh
npm install @bitty/maybe --save# For Yarn, use the command below.
yarn add @bitty/maybe
```### Installation from CDN
This module has a UMD bundle available through JSDelivr and Unpkg CDNs.
```html
// UMD module is exposed through the "Maybe" global object.
Maybe.fromFalsy(document.querySelector('input#id'))
.chain((el) => Maybe.fromFalsy(el.value?.trim()))
.map(console.log);```
## Examples
- [`getLanguage`](./examples/getLanguage/getLanguage.ts) is a function that resolves language in application. Its a pretty common case and it was implemented in the way I think we should use `Maybe`.
## License
Released under [MIT License](./LICENSE).