jklmli / monapt

Options, Tries, and Futures for JavaScript / TypeScript
MIT License
172 stars 13 forks source link

Monapt

npm version Build Status Coverage Status

semantic-release Commitizen friendly Conventional Commits

Monapt helps you better manage null, undefined, exceptions, and other mildly interesting phenomena. It handles them through the Option, Try, and Future abstractions.

Setup

$ npm install monapt

APIs

Usage

import { Option } from 'monapt';

Option(1)
  .map((x) => x * 2)
  .getOrElse(() => 4);

Docs are undergoing a redesign, and will be published on a separate site. In the meantime, the sources for the Option, Future, and Try classes are readable.

You can also take a look at the tests to get a feel for how to use them.

Changes in 1.0

1.0 was a complete rewrite of Monapt - including everything from the implementation to the tooling to the tests. The result is almost the same API, but more true to the original Scala interface.

Migrating from 0.7.1

Breaking Changes

These are all backed by type definitions, so compiling your code via TypeScript should reveal any breakages.

Credits

This repo couldn't have been possible without yaakaito/monapt. In his absence, I'll continue improving upon his hard work.