mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Optimize lodash function to avoid slow path for arrays.
Former-commit-id: 24e2c4ac2525ae38e214fdb0ea8e3ab664d784b7
This commit is contained in:
19
lodash.js
19
lodash.js
@@ -212,14 +212,15 @@
|
||||
* implicitly or explicitly included in the build.
|
||||
*
|
||||
* The chainable wrapper functions are:
|
||||
* `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`,
|
||||
* `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`,
|
||||
* `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`,
|
||||
* `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`,
|
||||
* `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `partialRight`,
|
||||
* `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`,
|
||||
* `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`,
|
||||
* `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip`
|
||||
* `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`,
|
||||
* `compose`, `concat`, `countBy`, `createCallback`, `debounce`, `defaults`,
|
||||
* `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`,
|
||||
* `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`,
|
||||
* `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
|
||||
* `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `push`, `range`,
|
||||
* `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`,
|
||||
* `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`,
|
||||
* `where`, `without`, `wrap`, and `zip`
|
||||
*
|
||||
* The non-chainable wrapper functions are:
|
||||
* `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`,
|
||||
@@ -241,7 +242,7 @@
|
||||
*/
|
||||
function lodash(value) {
|
||||
// don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
|
||||
return (value && typeof value == 'object' && hasOwnProperty.call(value, '__wrapped__'))
|
||||
return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
|
||||
? value
|
||||
: new lodashWrapper(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user