Unify provides a generic monad/functor higher order functions which work on multiple libraries. ImmutableJS, Maybe type, RxJS and Arrays. They all work using the same higher order function.
It uses conditional types in TypeScript 2.8 to not lose type information
npm install unify --save
Map works on an array
const array: Array<number> = [1, 2, 3];
const fn = (x: number) => x * 2;
const timesTwo: Array<number> = map(fn)(array);
Works on the Maybe type
const maybeNumber: Maybe<number> = maybe(1);
const fn = (x: number) => x * 2;
const timesTwo: Maybe<number> = map(fn)(maybeNumber);
Works on Observables!
const stream$: Observable<number> = of(1, 2, 3);
const fn = (x: number) => x * 2;
const timesTwo$: Observable<number> = map(fn)(stream$);
Works on ImmutableJS!
const list: List<number> = List.of(1, 2, 3);
const fn = (x: number) => x * 2;
const timesTwo: List<number> = map(fn)(list);
npm install unify --save
npm run test
- Christopher Horobin - Initial work - (https://github.com/chorobin)
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details
- RxJS
- ImmutableJS
- Monads!