mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Move lodash instance check up in lodash function and tweak chaining benchmark.
Former-commit-id: 799ae05e5180ee87bb2a5249be3e442ed0425ef7
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user