UNPKG

rambdax

Version:

Extended version of Rambda - a lightweight, faster alternative to Ramda

19 lines (16 loc) 371 B
export function compose(...fns){ if (fns.length === 0){ throw new Error('compose requires at least one argument') } return (...args) => { const list = fns.slice() if (list.length > 0){ const fn = list.pop() let result = fn(...args) while (list.length > 0){ result = list.pop()(result) } return result } } }