]> gerrit.simantics Code Review - simantics/district.git/blob - partial.js
bf31a3575a56dfe96e3f663ec7173f7f53010099
[simantics/district.git] / partial.js
1 'use strict';
2
3 var callable     = require('../../object/valid-callable')
4   , aFrom        = require('../../array/from')
5   , defineLength = require('../_define-length')
6
7   , apply = Function.prototype.apply;
8
9 module.exports = function (/*…args*/) {
10         var fn = callable(this)
11           , args = aFrom(arguments);
12
13         return defineLength(function () {
14                 return apply.call(fn, this, args.concat(aFrom(arguments)));
15         }, fn.length - args.length);
16 };