ts-belt
Fast, modern, and practical utility library for FP in TypeScript.
README
Fast, modern, and practical utility library for FP in TypeScript.
Documentation
Full documentation can be found here.
Features
- 🚀 built with ReScript, which generates highly performant JavaScript code (see the benchmark results here)
- 👀 provides more readable code, due to the data-first approach
- ✨ supports TypeScript and Flow
- 🛡 helps you write safer code with Option and Result types
- 🎯 all functions return immutable data (no side-effects)
- 🌲 tree-shakeable
- 📝 fully documented
Getting started
Installation
- ``` sh
- yarn add @mobily/ts-belt
- ```
or with npm
- ``` sh
- npm install @mobily/ts-belt --save
- ```
Usage
Module | Namespace | Description |
---|---|---|
|--|-----------|--| | ||
[Array](https://mobily.github.io/ts-belt/api/array) | A | Utility |
[Boolean](https://mobily.github.io/ts-belt/api/boolean) | B | Utility |
[Number](https://mobily.github.io/ts-belt/api/number) | N | Utility |
[Object | D | Utility |
[String](https://mobily.github.io/ts-belt/api/string) | S | Utility |
[Guards](https://mobily.github.io/ts-belt/api/guards) | G | Various |
[Option](https://mobily.github.io/ts-belt/api/option) | O | Functions |
[Result](https://mobily.github.io/ts-belt/api/result) | R | Functions |
[Function](https://mobily.github.io/ts-belt/api/function) | F | Other |
- ```typescript
- import { A, O, N, pipe } from '@mobily/ts-belt'
- pipe(
- [1, 2, 3, 4, 5], // → [1, 2, 3, 4, 5]
- A.dropExactly(2), // → Some([3, 4, 5])
- O.flatMap(A.head), // → Some(3)
- O.map(N.multiply(10)), // → Some(30)
- O.getWithDefault(0), // → 30
- ) // → 30
- ```
Contributors
License
The MIT License.
See LICENSE