UNPKG

monad-ts

Version:

Monad-ts is a small library implements some of key monads and way to chain them in a pipe (flow) in JavaScript and TypeScript. Angular 2+ compatible.

18 lines (17 loc) 644 B
import { Monad } from "./monad"; import { Pr } from "./types/pr"; import { MF } from "./types/mf"; /** * Class ErrorM - return given value or produce Error if take Error or get Error after execution of f(v). * @extends {Monad} */ export declare class ErrorM<T> extends Monad<T> { /** * Chains the operations on a monadic values. * @method bind * @param {function(v: T) => Pr<U>} f - transformation function for a monad. * @param {any} v - underlying value for a monad. * @return {Pr<U> | Error} transformed by f() value v or Error. */ bind<T, U>(f: MF<T, U>, v: any): Pr<U> | Error; }