partial.js 341 B

123456789101112131415
  1. var slice = require('../array/slice');
  2. /**
  3. * Creates a partially applied function.
  4. */
  5. function partial(fn, var_args){
  6. var argsArr = slice(arguments, 1); //curried args
  7. return function(){
  8. return fn.apply(this, argsArr.concat(slice(arguments)));
  9. };
  10. }
  11. module.exports = partial;