mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Update build to add _.findWhere as an alias of _.find for the underscore build.
Former-commit-id: 0b772c30749c9af6ddc20b7b786f282ea93b63ce
This commit is contained in:
20
build.js
20
build.js
@@ -42,7 +42,10 @@
|
||||
'select': 'filter',
|
||||
'tail': 'rest',
|
||||
'take': 'first',
|
||||
'unique': 'uniq'
|
||||
'unique': 'uniq',
|
||||
|
||||
// method used by the `backbone` and `underscore` builds
|
||||
'findWhere': 'find'
|
||||
};
|
||||
|
||||
/** Used to associate real names with their aliases */
|
||||
@@ -51,7 +54,7 @@
|
||||
'contains': ['include'],
|
||||
'every': ['all'],
|
||||
'filter': ['select'],
|
||||
'find': ['detect'],
|
||||
'find': ['detect', 'findWhere'],
|
||||
'first': ['head', 'take'],
|
||||
'forEach': ['each'],
|
||||
'functions': ['methods'],
|
||||
@@ -248,7 +251,6 @@
|
||||
'forOwn',
|
||||
'isPlainObject',
|
||||
'merge',
|
||||
'partial',
|
||||
'partialRight'
|
||||
]));
|
||||
|
||||
@@ -1850,6 +1852,13 @@
|
||||
' }'
|
||||
].join('\n'));
|
||||
|
||||
// replace `_.where`
|
||||
source = replaceFunction(source, 'where', [
|
||||
' function where(collection, properties, first) {',
|
||||
' return (first ? find : filter)(collection, properties);',
|
||||
' }'
|
||||
].join('\n'));
|
||||
|
||||
// replace `_.without`
|
||||
source = replaceFunction(source, 'without', [
|
||||
' function without(array) {',
|
||||
@@ -1867,6 +1876,11 @@
|
||||
' }'
|
||||
].join('\n'));
|
||||
|
||||
// add `_.findWhere` alias of `_.find`
|
||||
source = source.replace(getMethodAssignments(source), function(match) {
|
||||
return match.replace(/^( *)lodash.find *=.+/m, '$&\n$1lodash.findWhere = find;');
|
||||
});
|
||||
|
||||
// remove `_.isEqual` use from `createCallback`
|
||||
source = source.replace(matchFunction(source, 'createCallback'), function(match) {
|
||||
return match.replace(/isEqual\(([^,]+), *([^,]+)[^)]+\)/, '$1 === $2');
|
||||
|
||||
@@ -193,7 +193,8 @@
|
||||
|
||||
// properties used by the `backbone` and `underscore` builds
|
||||
'__chain__',
|
||||
'chain'
|
||||
'chain',
|
||||
'findWhere'
|
||||
];
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user