mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Sync underscore build with Underscore v1.5.1.
Former-commit-id: 333f720645f5ffec079bfe11558ed72a3956ed18
This commit is contained in:
64
build.js
64
build.js
@@ -2944,7 +2944,7 @@
|
||||
if (!isLodash('toArray')) {
|
||||
funcDepMap.toArray.push('isArray', 'map');
|
||||
}
|
||||
if (!isLodash('findWhere') || !isLodash('where')) {
|
||||
if (!isLodash('findWhere') && !isLodash('where')) {
|
||||
_.pull(funcDepMap.createCallback, 'baseIsEqual');
|
||||
funcDepMap.where.push('find', 'isEmpty');
|
||||
}
|
||||
@@ -3483,7 +3483,7 @@
|
||||
'}'
|
||||
].join('\n'));
|
||||
}
|
||||
// add Underscore's `_.findWhere`
|
||||
// add Underscore's `_.findWhere` and `_.where`
|
||||
if (!isLodash('findWhere') && !isLodash('where')) {
|
||||
source = source.replace(matchFunction(source, 'find'), function(match) {
|
||||
var indent = getIndent(match);
|
||||
@@ -3519,6 +3519,24 @@
|
||||
].join('\n' + indent));
|
||||
});
|
||||
|
||||
// replace `_.where`
|
||||
source = replaceFunction(source, 'where', [
|
||||
'function where(collection, properties, first) {',
|
||||
' return (first && isEmpty(properties))',
|
||||
' ? undefined',
|
||||
' : (first ? find : filter)(collection, properties);',
|
||||
'}'
|
||||
].join('\n'));
|
||||
|
||||
// simplify `_.createCallback`
|
||||
source = source.replace(matchFunction(source, 'createCallback'), function(match) {
|
||||
return match
|
||||
// remove unnecessary fast path
|
||||
.replace(/^(( *)var props *=.+?),[\s\S]+?\n\2}/m, '$1;')
|
||||
// remove `baseIsEqual` use
|
||||
.replace(/=.+?\bbaseIsEqual\((.+?), *(.+?),.+?\)/, '= $1 === $2');
|
||||
});
|
||||
|
||||
// replace alias assignment
|
||||
source = source.replace(getMethodAssignments(source), function(match) {
|
||||
return match.replace(/^( *lodash.findWhere *= *).+/m, '$1findWhere;');
|
||||
@@ -3737,15 +3755,6 @@
|
||||
'}'
|
||||
].join('\n'));
|
||||
}
|
||||
// replace `_.result`
|
||||
if (!isLodash('result')) {
|
||||
source = replaceFunction(source, 'result', [
|
||||
'function result(object, property) {',
|
||||
' var value = object ? object[property] : undefined;',
|
||||
' return isFunction(value) ? object[property]() : value;',
|
||||
'}'
|
||||
].join('\n'));
|
||||
}
|
||||
// replace `_.sortBy`
|
||||
if (!isLodash('sortBy')) {
|
||||
source = replaceFunction(source, 'sortBy', [
|
||||
@@ -3854,20 +3863,6 @@
|
||||
'}'
|
||||
].join('\n'));
|
||||
}
|
||||
// replace `_.times`
|
||||
if (!isLodash('times')) {
|
||||
source = replaceFunction(source, 'times', [
|
||||
'function times(n, callback, thisArg) {',
|
||||
' var index = -1,',
|
||||
' result = Array(n > -1 ? n : 0);',
|
||||
'',
|
||||
' while (++index < n) {',
|
||||
' result[index] = callback.call(thisArg, index);',
|
||||
' }',
|
||||
' return result;',
|
||||
'}'
|
||||
].join('\n'));
|
||||
}
|
||||
// replace `_.toArray`
|
||||
if (!isLodash('toArray')) {
|
||||
source = replaceFunction(source, 'toArray', [
|
||||
@@ -3919,25 +3914,6 @@
|
||||
'}'
|
||||
].join('\n'));
|
||||
}
|
||||
// replace `_.where`
|
||||
if (!isLodash('where')) {
|
||||
source = replaceFunction(source, 'where', [
|
||||
'function where(collection, properties, first) {',
|
||||
' return (first && isEmpty(properties))',
|
||||
' ? undefined',
|
||||
' : (first ? find : filter)(collection, properties);',
|
||||
'}'
|
||||
].join('\n'));
|
||||
|
||||
// simplify `_.createCallback`
|
||||
source = source.replace(matchFunction(source, 'createCallback'), function(match) {
|
||||
return match
|
||||
// remove unnecessary fast path
|
||||
.replace(/^(( *)var props *=.+?),[\s\S]+?\n\2}/m, '$1;')
|
||||
// remove `baseIsEqual` use
|
||||
.replace(/=.+?\bbaseIsEqual\((.+?), *(.+?),.+?\)/, '= $1 === $2');
|
||||
});
|
||||
}
|
||||
// replace `_.zip`
|
||||
if(!isLodash('zip')) {
|
||||
source = replaceFunction(source, 'zip', [
|
||||
|
||||
Reference in New Issue
Block a user