ts-belt

Fast, modern, and practical utility library for FP in TypeScript.
GitHub
1.16k
Created 4 years ago, last commit 2 years ago
8 contributors
448 commits
Stars added on GitHub, month by month
4
5
6
7
8
9
10
11
12
1
2
3
2024
2025
Stars added on GitHub, per day, on average
Yesterday
=
Last week
+0.7
/day
Last month
+0.3
/day
Last 12 months
+0.3
/day
npmPackage on NPM
Monthly downloads on NPM
4
5
6
7
8
9
10
11
12
1
2
3
2024
2025
No dependencies
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

yarn add @mobily/ts-belt

or with npm

npm install @mobily/ts-belt --save

Usage

Module Namespace Description
Array A Utility functions for Array.
Boolean B Utility functions for Boolean.
Number N Utility functions for Number.
Object (Dict) D Utility functions for Object.
String S Utility functions for String.
Guards G Various TypeScript guards.
Option O Functions for handling the Option data type that represents the existence and nonexistence of a value.
Result R Functions for describing the result of a certain operation without relying on exceptions.
Function F Other useful functions.
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


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.

See LICENSE