X7ROOT File Manager
Current Path:
/lib/node_modules/npm/node_modules/function-bind
lib
/
node_modules
/
npm
/
node_modules
/
function-bind
/
??
..
??
.editorconfig
(286 B)
??
.jscs.json
(4.04 KB)
??
.npmignore
(252 B)
??
.travis.yml
(5.32 KB)
??
LICENSE
(1.03 KB)
??
README.md
(1.45 KB)
??
implementation.js
(1.43 KB)
??
index.js
(126 B)
??
package.json
(1.69 KB)
Editing: implementation.js
'use strict'; /* eslint no-invalid-this: 1 */ var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible '; var slice = Array.prototype.slice; var toStr = Object.prototype.toString; var funcType = '[object Function]'; module.exports = function bind(that) { var target = this; if (typeof target !== 'function' || toStr.call(target) !== funcType) { throw new TypeError(ERROR_MESSAGE + target); } var args = slice.call(arguments, 1); var bound; var binder = function () { if (this instanceof bound) { var result = target.apply( this, args.concat(slice.call(arguments)) ); if (Object(result) === result) { return result; } return this; } else { return target.apply( that, args.concat(slice.call(arguments)) ); } }; var boundLength = Math.max(0, target.length - args.length); var boundArgs = []; for (var i = 0; i < boundLength; i++) { boundArgs.push('$' + i); } bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder); if (target.prototype) { var Empty = function Empty() {}; Empty.prototype = target.prototype; bound.prototype = new Empty(); Empty.prototype = null; } return bound; };
Upload File
Create Folder