Sha256: 6b4ea26f8ca351cee55da416500ffca72fdb14eb5909f1512ce8ca68e47d7621

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 KB

Contents

'use strict';

var bind = require('function-bind');
var GetIntrinsic = require('get-intrinsic');
var setFunctionLength = require('set-function-length');

var $TypeError = require('es-errors/type');
var $apply = GetIntrinsic('%Function.prototype.apply%');
var $call = GetIntrinsic('%Function.prototype.call%');
var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);

var $defineProperty = require('es-define-property');
var $max = GetIntrinsic('%Math.max%');

module.exports = function callBind(originalFunction) {
	if (typeof originalFunction !== 'function') {
		throw new $TypeError('a function is required');
	}
	var func = $reflectApply(bind, $call, arguments);
	return setFunctionLength(
		func,
		1 + $max(0, originalFunction.length - (arguments.length - 1)),
		true
	);
};

var applyBind = function applyBind() {
	return $reflectApply(bind, $apply, arguments);
};

if ($defineProperty) {
	$defineProperty(module.exports, 'apply', { value: applyBind });
} else {
	module.exports.apply = applyBind;
}

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
immosquare-cleaner-0.1.52 node_modules/call-bind/index.js
immosquare-cleaner-0.1.51 node_modules/call-bind/index.js
immosquare-cleaner-0.1.50 node_modules/call-bind/index.js
immosquare-cleaner-0.1.49 node_modules/call-bind/index.js
immosquare-cleaner-0.1.48 node_modules/call-bind/index.js
immosquare-cleaner-0.1.47 node_modules/call-bind/index.js
immosquare-cleaner-0.1.46 node_modules/call-bind/index.js
immosquare-cleaner-0.1.45 node_modules/call-bind/index.js
immosquare-cleaner-0.1.44 node_modules/call-bind/index.js
immosquare-cleaner-0.1.43 node_modules/call-bind/index.js
immosquare-cleaner-0.1.42 node_modules/call-bind/index.js
immosquare-cleaner-0.1.41 node_modules/call-bind/index.js
immosquare-cleaner-0.1.40 node_modules/call-bind/index.js
immosquare-cleaner-0.1.39 node_modules/call-bind/index.js
immosquare-cleaner-0.1.38 node_modules/call-bind/index.js