X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=node_modules%2Fcore-js%2Flibrary%2Fmodules%2F_bind.js;fp=node_modules%2Fcore-js%2Flibrary%2Fmodules%2F_bind.js;h=1f7b0174ba6588496d414bd1ae1a86a1f95f7eda;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/node_modules/core-js/library/modules/_bind.js b/node_modules/core-js/library/modules/_bind.js new file mode 100644 index 000000000..1f7b0174b --- /dev/null +++ b/node_modules/core-js/library/modules/_bind.js @@ -0,0 +1,24 @@ +'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; +}; \ No newline at end of file