source: imaps-frontend/node_modules/call-bind/index.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.0 KB
Line 
1'use strict';
2
3var bind = require('function-bind');
4var GetIntrinsic = require('get-intrinsic');
5var setFunctionLength = require('set-function-length');
6
7var $TypeError = require('es-errors/type');
8var $apply = GetIntrinsic('%Function.prototype.apply%');
9var $call = GetIntrinsic('%Function.prototype.call%');
10var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
11
12var $defineProperty = require('es-define-property');
13var $max = GetIntrinsic('%Math.max%');
14
15module.exports = function callBind(originalFunction) {
16 if (typeof originalFunction !== 'function') {
17 throw new $TypeError('a function is required');
18 }
19 var func = $reflectApply(bind, $call, arguments);
20 return setFunctionLength(
21 func,
22 1 + $max(0, originalFunction.length - (arguments.length - 1)),
23 true
24 );
25};
26
27var applyBind = function applyBind() {
28 return $reflectApply(bind, $apply, arguments);
29};
30
31if ($defineProperty) {
32 $defineProperty(module.exports, 'apply', { value: applyBind });
33} else {
34 module.exports.apply = applyBind;
35}
Note: See TracBrowser for help on using the repository browser.