Move lodash instance check up in lodash function and tweak chaining benchmark.

Former-commit-id: 799ae05e5180ee87bb2a5249be3e442ed0425ef7
This commit is contained in:
John-David Dalton
2013-03-04 01:40:55 -08:00
parent 9f19c302d8
commit 35bd7c55d0
9 changed files with 24 additions and 24 deletions

View File

@@ -319,14 +319,14 @@
* @returns {Object} Returns a `lodash` instance.
*/
function lodash(value) {
// exit early if already wrapped, even if wrapped by a different `lodash` constructor
if (value && typeof value == 'object' && hasOwnProperty.call(value, '__wrapped__')) {
return value;
}
// allow invoking `lodash` without the `new` operator
if (!(this instanceof lodash)) {
return new lodash(value);
}
// exit early if already wrapped, even if wrapped by a different `lodash` constructor
if (value && typeof value == 'object' && hasOwnProperty.call(value, '__wrapped__')) {
return value;
}
this.__wrapped__ = value;
}