mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Rework lodash.
This commit is contained in:
16
lodash.js
16
lodash.js
@@ -791,10 +791,13 @@
|
||||
* // => true
|
||||
*/
|
||||
function lodash(value) {
|
||||
// don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
|
||||
return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
|
||||
? value
|
||||
: new lodashWrapper(value);
|
||||
if (value instanceof lodashWrapper) {
|
||||
return value;
|
||||
}
|
||||
if (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__')) {
|
||||
value = value.__wrapped__;
|
||||
}
|
||||
return new lodashWrapper(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -809,8 +812,6 @@
|
||||
this.__chain__ = !!chainAll;
|
||||
this.__wrapped__ = value;
|
||||
}
|
||||
// ensure `new lodashWrapper` is an instance of `lodash`
|
||||
lodashWrapper.prototype = lodash.prototype;
|
||||
|
||||
/**
|
||||
* An object used to flag environments features.
|
||||
@@ -8605,6 +8606,9 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// ensure `new lodashWrapper` is an instance of `lodash`
|
||||
lodashWrapper.prototype = lodash.prototype;
|
||||
|
||||
// add functions that return wrapped values when chaining
|
||||
lodash.after = after;
|
||||
lodash.assign = assign;
|
||||
|
||||
Reference in New Issue
Block a user