Monapt
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
; Option1 .mapx * 2 .getOrElse4;
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 toOption::flatten
.Monapt::future
has been renamed toFuture::create
. It now accepts awhen.Promise<A> | when.Thenable<A> | A
.Option#reject
has been renamed toOption#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.