Add _.findIndex and _.findKey. [closes #199]

Former-commit-id: 5ac98b559e074082d4019cd30c27bface063f9c9
This commit is contained in:
John-David Dalton
2013-03-17 19:28:46 -05:00
parent e941de50e8
commit 2dc539747b
5 changed files with 152 additions and 42 deletions

View File

@@ -97,6 +97,7 @@
'compact',
'difference',
'drop',
'findIndex',
'first',
'flatten',
'head',
@@ -187,6 +188,7 @@
'cloneDeep',
'defaults',
'extend',
'findKey',
'forIn',
'forOwn',
'functions',
@@ -293,6 +295,8 @@
'bindKey',
'cloneDeep',
'createCallback',
'findIndex',
'findKey',
'forIn',
'forOwn',
'isPlainObject',
@@ -946,6 +950,8 @@
'at',
'bindKey',
'createCallback',
'findIndex',
'findKey',
'forIn',
'forOwn',
'isPlainObject',
@@ -1362,6 +1368,9 @@
isUnderscore = /backbone|underscore/.test(command),
exposeAssign = !isUnderscore,
exposeCreateCallback = !isUnderscore,
exposeForIn = !isUnderscore,
exposeForOwn = !isUnderscore,
exposeIsPlainObject = !isUnderscore,
exposeZipObject = !isUnderscore;
try {
@@ -1418,12 +1427,24 @@
// remove nonexistent and duplicate method names
methodNames = _.uniq(_.intersection(allMethods, expandMethodNames(methodNames)));
if (isUnderscore) {
methodNames = _.without.apply(_, [methodNames].concat(['findIndex', 'findKey']));
}
if (!exposeAssign) {
methodNames = _.without(methodNames, 'assign');
}
if (!exposeCreateCallback) {
methodNames = _.without(methodNames, 'createCallback');
}
if (!exposeForIn) {
methodNames = _.without(methodNames, 'forIn');
}
if (!exposeForOwn) {
methodNames = _.without(methodNames, 'forOwn');
}
if (!exposeIsPlainObject) {
methodNames = _.without(methodNames, 'isPlainobject');
}
if (!exposeZipObject) {
methodNames = _.without(methodNames, 'zipObject');
}