_executeBound.js 609 B

123456789101112131415
  1. var _baseCreate = require('./_baseCreate.js');
  2. var isObject = require('./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. 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. }
  13. module.exports = executeBound;