import { Curry , Fn } from './types' ; param f export const curry = < F extends Fn > ( f ) : Curry < F > => { return curriedN ( f . length , f , [ ] ) as Curry < F > ; } ; function curriedN < Args extends any [ ] , R > ( arity , f , previousArgs ) { if ( arity < 2 ) { return f ; } return ( ... args ) => { const concatArgs = previousArgs . concat ( args ) as Args ; return concatArgs . length >= arity ? f ( ... concatArgs ) : curriedN ( arity , f , concatArgs ) ; } ; }