Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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).