source: trip-planner-front/node_modules/core-js/internals/function-bind.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1'use strict';
2var aFunction = require('../internals/a-function');
3var isObject = require('../internals/is-object');
4
5var slice = [].slice;
6var factories = {};
7
8var construct = function (C, argsLength, args) {
9 if (!(argsLength in factories)) {
10 for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
11 // eslint-disable-next-line no-new-func -- we have no proper alternatives, IE8- only
12 factories[argsLength] = Function('C,a', 'return new C(' + list.join(',') + ')');
13 } return factories[argsLength](C, args);
14};
15
16// `Function.prototype.bind` method implementation
17// https://tc39.es/ecma262/#sec-function.prototype.bind
18module.exports = Function.bind || function bind(that /* , ...args */) {
19 var fn = aFunction(this);
20 var partArgs = slice.call(arguments, 1);
21 var boundFunction = function bound(/* args... */) {
22 var args = partArgs.concat(slice.call(arguments));
23 return this instanceof boundFunction ? construct(fn, args.length, args) : fn.apply(that, args);
24 };
25 if (isObject(fn.prototype)) boundFunction.prototype = fn.prototype;
26 return boundFunction;
27};
Note: See TracBrowser for help on using the repository browser.