import { ArityN } from '../types' ; import { CurryNFn } from './types' ; name export const curryN = curriedN ( 2 , ( arity , f ) => curriedN ( arity , f , [ ] ) , [ ] ) ; function curriedN ( arity , f , previousArgs ) { if ( arity <= 1 ) return f ; return function ( ... args ) { const concatArgs = previousArgs . concat ( args ) ; if ( concatArgs . length >= arity ) return f . apply ( this , concatArgs ) ; return curriedN ( arity , f , concatArgs ) ; } ; }