ts-belt

Fast, modern, and practical utility library for FP in TypeScript.

README

Build Status Coverage npm PRs Welcome All Contributors GitHub license

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


  1. ``` sh
  2. yarn add @mobily/ts-belt
  3. ```

or with npm

  1. ``` sh
  2. npm install @mobily/ts-belt --save
  3. ```

Usage


ModuleNamespaceDescription
|--|-----------|--|
[Array](https://mobily.github.io/ts-belt/api/array)AUtility
[Boolean](https://mobily.github.io/ts-belt/api/boolean)BUtility
[Number](https://mobily.github.io/ts-belt/api/number)NUtility
[ObjectDUtility
[String](https://mobily.github.io/ts-belt/api/string)SUtility
[Guards](https://mobily.github.io/ts-belt/api/guards)GVarious
[Option](https://mobily.github.io/ts-belt/api/option)OFunctions
[Result](https://mobily.github.io/ts-belt/api/result)RFunctions
[Function](https://mobily.github.io/ts-belt/api/function)FOther

  1. ```typescript
  2. import { A, O, N, pipe } from '@mobily/ts-belt'

  3. pipe(
  4.   [1, 2, 3, 4, 5], // → [1, 2, 3, 4, 5]
  5.   A.dropExactly(2), // → Some([3, 4, 5])
  6.   O.flatMap(A.head), // → Some(3)
  7.   O.map(N.multiply(10)), // → Some(30)
  8.   O.getWithDefault(0), // → 30
  9. ) // → 30
  10. ```


Contributors






Marcin Dziewulski

💻 📖 ⚠️ 🎨 🚧

Krzysztof Lenda

📖

Radek Kozieł

📖

Artur

📖

Dominik Łopaciński

💻 📖 ⚠️

Jakub Wąsik

📖

Krystian Mateusiak

💻 📖 ⚠️

Michał Miszczyszyn

🤔

Kevin

📖

Anthony Khong

💻 📖 ⚠️

Pyrolistical

📖 🚧 🤔

Mathieu Acthernoene

🤔






License


The MIT License.