UNPKG

wraptile

Version:

translate the evaluation of a function that takes multiple arguments into evaluating a sequence of 2 functions, each with any count of arguments

19 lines (12 loc) 312 B
'use strict'; const wrap = (fn) => (...a) => (...b) => fn(...a, ...b); module.exports = (fn, ...a) => { check(fn); if (a.length) return wrap(fn)(...a); return wrap(fn); }; function check(fn) { if (typeof fn !== 'function') throw Error('fn should be a function!'); }