import { UnknownError } from './unknown-error' ; export type IMapFn < A , B > = ( a : A ) => B ; export type ITaskChainFn < A , B , E > = ( value : A ) => Task < B , E > ; export type IPipeFn < T1 , T2 , E1 , E2 > = ( a : Task < T1 , E1 > ) => Task < T2 , E2 > ; param T param E export class Task < T , E > { param resolver constructor ( private resolver ) { } static resolve < T , E = never > ( value ) { return new Task ( resolve => { resolve ( value ) ; } ) ; } static reject < E , T = never > ( error ) { return new Task ( ( resolve , reject ) => { reject ( error ) ; } ) ; } fork ( errorFn , successFn ) { new Promise ( ( resolve , reject ) => { this . resolver ( resolve , reject ) ; } ) . then ( ( x ) => successFn ( x ) , errorFn ) ; } }