Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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

  • All default exports have been removed to avoid ambiguity.
  • Future now depends on native ES6 Promises, and uses them internally when representing promises. Make sure to include a shim if you plan on using Futures.
  • Future#onFailure has been removed.
  • Future#onSuccess has been removed.
  • Future#reject has been removed.
  • Monapt::flatten has been renamed to Option::flatten.
  • Monapt::future has been renamed to Future::create. It now accepts a when.Promise<A> | when.Thenable<A> | A.
  • Option#reject has been renamed to Option#filterNot.
  • Try#reject has been removed.

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.

About

Options, Tries, and Futures for JavaScript / TypeScript

Resources

License

Packages

No packages published
You can’t perform that action at this time.