index.js 643 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. var setFunctionLength = require('set-function-length');
  3. var $defineProperty = require('es-define-property');
  4. var callBindBasic = require('call-bind-apply-helpers');
  5. var applyBind = require('call-bind-apply-helpers/applyBind');
  6. module.exports = function callBind(originalFunction) {
  7. var func = callBindBasic(arguments);
  8. var adjustedLength = originalFunction.length - (arguments.length - 1);
  9. return setFunctionLength(
  10. func,
  11. 1 + (adjustedLength > 0 ? adjustedLength : 0),
  12. true
  13. );
  14. };
  15. if ($defineProperty) {
  16. $defineProperty(module.exports, 'apply', { value: applyBind });
  17. } else {
  18. module.exports.apply = applyBind;
  19. }