export type TPipeFunction < T > = ( arg : T ) => T ; export function pipe < T > ( ... fns ) { return ( arg ) : T => fns . reduce ( ( param , f ) => f ( param ) , arg ) ; } export function compose < T > ( ... fns ) { return ( arg ) : T => fns . reduceRight ( ( param , f ) => f ( param ) , arg ) ; } export const curry = ( fn , ... args ) => ( arg ) : any => args . length === fn . length - 1 ? fn ( ... args , arg ) : curry ( fn , ... args , arg ) ; export const flipCurry = ( fn , ... args ) => ( arg ) : any => args . length === fn . length - 1 ? fn ( arg , ... args . reverse ( ) ) : flipCurry ( fn , ... args , arg ) ;