MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / createCtorWrapper

Function createCtorWrapper

lib/web/jshint.js:4721–4730  ·  view source on GitHub ↗

* Creates a function that produces an instance of `Ctor` regardless of * whether it was invoked as part of a `new` expression or by `call` or `apply`. * * @private * @param {Function} Ctor The constructor to wrap. * @returns {Function} Returns the new wrapped function.

(Ctor)

Source from the content-addressed store, hash-verified

4719 * @returns {Function} Returns the new wrapped function.
4720 */
4721 function createCtorWrapper(Ctor) {
4722 return function() {
4723 var thisBinding = baseCreate(Ctor.prototype),
4724 result = Ctor.apply(thisBinding, arguments);
4725
4726 // Mimic the constructor's `return` behavior.
4727 // See https://es5.github.io/#x13.2.2 for more details.
4728 return isObject(result) ? result : thisBinding;
4729 };
4730 }
4731
4732 /**
4733 * Creates a `_.curry` or `_.curryRight` function.

Callers 4

createBindWrapperFunction · 0.85
createHybridWrapperFunction · 0.85
wrapperFunction · 0.85
createPartialWrapperFunction · 0.85

Calls 2

isObjectFunction · 0.70
applyMethod · 0.65

Tested by

no test coverage detected