Awesome
<p align="center"> <img src="https://raw.githubusercontent.com/mobily/ts-belt/master/assets/ts-belt-frame.png" width="480"> </p> <p align="center"> <a href="https://app.circleci.com/pipelines/github/mobily/ts-belt"> <img src="https://img.shields.io/circleci/build/github/mobily/ts-belt.svg?style=flat-square&logo=circleci" alt="Build Status"> </a> <a href="https://coveralls.io/github/mobily/ts-belt?branch=master"> <img src="https://img.shields.io/coveralls/github/mobily/ts-belt.svg?style=flat-square&logo=coveralls" alt="Coverage"> </a> <a href="https://www.npmjs.com/package/@mobily/ts-belt"> <img src="https://img.shields.io/npm/v/@mobily/ts-belt.svg?style=flat-square&logo=npm" alt="npm"> </a> <a href="http://makeapullrequest.com"> <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs Welcome"> </a> <a href="#contributors"> <img src="https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square" alt="All Contributors"> </a> <a href="https://github.com/mobily/ts-belt/blob/master/LICENSE"> <img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="GitHub license"> </a> </p> <p align="center"> <strong>Fast, modern, and practical utility library for FP in TypeScript.</strong> </p>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
andFlow
- π‘ helps you write safer code with
Option
andResult
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
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tr> <td align="center"><a href="https://twitter.com/__marcin_"><img src="https://avatars1.githubusercontent.com/u/1467712?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Marcin Dziewulski</b></sub></a><br /><a href="https://github.com/mobily/ts-belt/commits?author=mobily" title="Code">π»</a> <a href="https://github.com/mobily/ts-belt/commits?author=mobily" title="Documentation">π</a> <a href="https://github.com/mobily/ts-belt/commits?author=mobily" title="Tests">β οΈ</a> <a href="#design-mobily" title="Design">π¨</a> <a href="#maintenance-mobily" title="Maintenance">π§</a></td> <td align="center"><a href="http://github.com/foull"><img src="https://avatars.githubusercontent.com/u/902819?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Krzysztof Lenda</b></sub></a><br /><a href="https://github.com/mobily/ts-belt/commits?author=foull" title="Documentation">π</a></td> <td align="center"><a href="https://github.com/panr"><img src="https://avatars.githubusercontent.com/u/1303365?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Radek KozieΕ</b></sub></a><br /><a href="https://github.com/mobily/ts-belt/commits?author=panr" title="Documentation">π</a></td> <td align="center"><a href="https://github.com/Fortidude"><img src="https://avatars.githubusercontent.com/u/8781462?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Artur</b></sub></a><br /><a href="https://github.com/mobily/ts-belt/commits?author=Fortidude" title="Documentation">π</a></td> <td align="center"><a href="https://github.com/domeknn"><img src="https://avatars.githubusercontent.com/u/9402280?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dominik ΕopaciΕski</b></sub></a><br /><a href="https://github.com/mobily/ts-belt/commits?author=domeknn" title="Code">π»</a> <a href="https://github.com/mobily/ts-belt/commits?author=domeknn" title="Documentation">π</a> <a href="https://github.com/mobily/ts-belt/commits?author=domeknn" title="Tests">β οΈ</a></td> <td align="center"><a href="https://github.com/Eghizio"><img src="https://avatars.githubusercontent.com/u/32049761?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jakub WΔ sik</b></sub></a><br /><a href="https://github.com/mobily/ts-belt/commits?author=Eghizio" title="Documentation">π</a></td> <td align="center"><a href="https://github.com/Dilven"><img src="https://avatars.githubusercontent.com/u/26671751?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Krystian Mateusiak</b></sub></a><br /><a href="https://github.com/mobily/ts-belt/commits?author=Dilven" title="Code">π»</a> <a href="https://github.com/mobily/ts-belt/commits?author=Dilven" title="Documentation">π</a> <a href="https://github.com/mobily/ts-belt/commits?author=Dilven" title="Tests">β οΈ</a></td> </tr> <tr> <td align="center"><a href="https://typeofweb.com/"><img src="https://avatars.githubusercontent.com/u/1338731?v=4?s=100" width="100px;" alt=""/><br /><sub><b>MichaΕ Miszczyszyn</b></sub></a><br /><a href="#ideas-mmiszy" title="Ideas, Planning, & Feedback">π€</a></td> <td align="center"><a href="https://github.com/remnantkevin"><img src="https://avatars.githubusercontent.com/u/8270635?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kevin</b></sub></a><br /><a href="https://github.com/mobily/ts-belt/commits?author=remnantkevin" title="Documentation">π</a></td> <td align="center"><a href="https://github.com/anthony-khong"><img src="https://avatars.githubusercontent.com/u/12151757?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Anthony Khong</b></sub></a><br /><a href="https://github.com/mobily/ts-belt/commits?author=anthony-khong" title="Code">π»</a> <a href="https://github.com/mobily/ts-belt/commits?author=anthony-khong" title="Documentation">π</a> <a href="https://github.com/mobily/ts-belt/commits?author=anthony-khong" title="Tests">β οΈ</a></td> <td align="center"><a href="http://pyrolistical.github.com/"><img src="https://avatars.githubusercontent.com/u/463642?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Pyrolistical</b></sub></a><br /><a href="https://github.com/mobily/ts-belt/commits?author=Pyrolistical" title="Documentation">π</a> <a href="#maintenance-Pyrolistical" title="Maintenance">π§</a> <a href="#ideas-Pyrolistical" title="Ideas, Planning, & Feedback">π€</a></td> <td align="center"><a href="https://zoontek.me/"><img src="https://avatars.githubusercontent.com/u/1902323?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mathieu Acthernoene</b></sub></a><br /><a href="#ideas-zoontek" title="Ideas, Planning, & Feedback">π€</a></td> </tr> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->License
The MIT License.
See LICENSE