@berhalak/monads
TypeScript icon, indicating that this package has built-in type declarations

0.0.11 • Public • Published

monads

Typescript monads

// sample usage
expect(lift(lift(5)).map(x => x + 6).value()).toBe(11);

// from constants
expect(lift(5).map(x => x + 6).value()).toBe(11);
expect(some(5).map(x => x + 6).value()).toBe(11);

// async support
expect(await wait(lift(5)).map(x => x + 6).value()).toBe(11);

// constant map
expect(await wait(5).map(x => x + 6).value()).toBe(11);
expect(await wait(5).map(x => x + 6).value()).toBe(11);

// move from normal monad to async
expect(await lift(4).map(async x => x + 5).wait().map(x=> x + 2).value()).toBe(11);

// fluent selector
expect(from([1,2]).map(x => x + 1).toArray()).toStrictEqual([2,3]);

Package Sidebar

Install

npm i @berhalak/monads

Weekly Downloads

1

Version

0.0.11

License

MIT

Unpacked Size

34.1 kB

Total Files

12

Last publish

Collaborators

  • berhalak