1.4.0 • Published 5 years ago

@nutgaard/maybe-ts v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Maybe-ts

styled with prettier Travis codecov dependencies Status

Maybe monad for typescript inspired by elm's Maybe.

Installation:

npm install @nutgaard/maybe-ts --save

Examples

The library exports two different ways of using the Maybe-monad, functional and classical.

NB! Uses different ways of importing the library.

Function:

import Maybe from 'maybe-ts';

Maybe.map((value) => value.toUpperCase(), Maybe.just('Hello, World'));

// If you use a library for `compose`/`flow`/`pipe` or similar concepts. (See ./test/pipe.ts example)
pipe(
  Maybe.just('Hello, World'),
  Maybe.map((value: string) => value.toUpperCase())
);

// Or, with the use of the pipe-operator
Maybe.just('Hello, World')
  |> Maybe.map((value) => value.toUpperCase())

Classical:

import { MaybeCls as Maybe } from '../src/maybe-ts';

Maybe.just('Hello, World')
  .map((value) => value.toUpperCase())

Types

Full documentation of types can be seen here

Credits

Made using the awesome typescript library starter

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago