partial.js 437 B

12345678910111213141516
  1. "use strict";
  2. var callable = require("../../object/valid-callable")
  3. , aFrom = require("../../array/from")
  4. , defineLength = require("../_define-length")
  5. , apply = Function.prototype.apply;
  6. module.exports = function (/* …args*/) {
  7. var fn = callable(this)
  8. , args = aFrom(arguments);
  9. return defineLength(function () {
  10. return apply.call(fn, this, args.concat(aFrom(arguments)));
  11. }, fn.length - args.length);
  12. };