mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Make _.where iterate over only own properties.
Former-commit-id: 29b4cafe5271cad70c711c2d401cea627fa97e33
This commit is contained in:
25
build.js
25
build.js
@@ -156,7 +156,7 @@
|
||||
'uniqueId': [],
|
||||
'value': ['mixin'],
|
||||
'values': ['forOwn'],
|
||||
'where': ['filter', 'forIn'],
|
||||
'where': ['filter', 'keys'],
|
||||
'without': ['indexOf'],
|
||||
'wrap': [],
|
||||
'zip': ['max', 'pluck']
|
||||
@@ -988,13 +988,14 @@
|
||||
dependencyMap.reduceRight = ['forEach', 'keys'];
|
||||
}
|
||||
if (isUnderscore) {
|
||||
dependencyMap.contains = ['forEach', 'indexOf'],
|
||||
dependencyMap.contains = ['forEach', 'indexOf'];
|
||||
dependencyMap.isEqual = ['isArray', 'isFunction'];
|
||||
dependencyMap.isEmpty = ['isArray', 'isString'];
|
||||
dependencyMap.max = ['forEach', 'isArray'];
|
||||
dependencyMap.min = ['forEach', 'isArray'];
|
||||
dependencyMap.pick = [];
|
||||
dependencyMap.template = ['defaults', 'escape'];
|
||||
dependencyMap.where = ['filter', 'forIn'];
|
||||
|
||||
if (useUnderscoreClone) {
|
||||
dependencyMap.clone = ['assign', 'isArray'];
|
||||
@@ -1255,6 +1256,26 @@
|
||||
' }'
|
||||
].join('\n'));
|
||||
|
||||
// replace `_.where`
|
||||
source = source.replace(/^( *)function where[\s\S]+?\n\1}/m, [
|
||||
' function where(collection, properties) {',
|
||||
' var props = [];',
|
||||
' forIn(properties, function(value, prop) {',
|
||||
' props.push(prop);',
|
||||
' });',
|
||||
' return filter(collection, function(object) {',
|
||||
' var length = props.length;',
|
||||
' while (length--) {',
|
||||
' var result = object[props[length]] === properties[props[length]];',
|
||||
' if (!result) {',
|
||||
' break;',
|
||||
' }',
|
||||
' }',
|
||||
' return !!result;',
|
||||
' });',
|
||||
' }'
|
||||
].join('\n'));
|
||||
|
||||
// replace `_.without`
|
||||
source = source.replace(/^( *)function without[\s\S]+?\n\1}/m, [
|
||||
' function without(array) {',
|
||||
|
||||
Reference in New Issue
Block a user