_executeBound.js 584 B

12345678910111213
  1. import baseCreate from './_baseCreate.js';
  2. import isObject from './isObject.js';
  3. // Internal function to execute `sourceFunc` bound to `context` with optional
  4. // `args`. Determines whether to execute a function as a constructor or as a
  5. // normal function.
  6. export default function executeBound(sourceFunc, boundFunc, context, callingContext, args) {
  7. if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
  8. var self = baseCreate(sourceFunc.prototype);
  9. var result = sourceFunc.apply(self, args);
  10. if (isObject(result)) return result;
  11. return self;
  12. }