Update build to add _.findWhere as an alias of _.find for the underscore build.

Former-commit-id: 0b772c30749c9af6ddc20b7b786f282ea93b63ce
This commit is contained in:
John-David Dalton
2013-01-30 00:39:33 -08:00
parent 812b848daf
commit 9763b6e2cf
2 changed files with 19 additions and 4 deletions

View File

@@ -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');

View File

@@ -193,7 +193,8 @@
// properties used by the `backbone` and `underscore` builds
'__chain__',
'chain'
'chain',
'findWhere'
];
/*--------------------------------------------------------------------------*/