2017-06-08_509bba0/509bba0_unpacked_with_node_modules/~/core-js/modules/_bind.js
2022-07-26 10:06:20 -07:00

31 lines
No EOL
966 B
JavaScript
Executable file

'use strict';
var aFunction = require('./_a-function')
, isObject = require('./_is-object')
, invoke = require('./_invoke')
, arraySlice = [].slice
, factories = {};
var construct = function(F, len, args){
if(!(len in factories)){
for(var n = [], i = 0; i < len; i++)n[i] = 'a[' + i + ']';
factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')');
} return factories[len](F, args);
};
module.exports = Function.bind || function bind(that /*, args... */){
var fn = aFunction(this)
, partArgs = arraySlice.call(arguments, 1);
var bound = function(/* args... */){
var args = partArgs.concat(arraySlice.call(arguments));
return this instanceof bound ? construct(fn, args.length, args) : invoke(fn, args, that);
};
if(isObject(fn.prototype))bound.prototype = fn.prototype;
return bound;
};
//////////////////
// WEBPACK FOOTER
// ./~/core-js/modules/_bind.js
// module id = 880
// module chunks = 4