Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 890b2a0

Browse files
committed
fixup: change param name (specialKey --> anyPropertyKey)
1 parent d59dbbc commit 890b2a0

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/ng/filter/filter.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
* Primitive values are converted to strings. Objects are not compared against primitives,
6161
* unless they have a custom `toString` method (e.g. `Date` objects).
6262
*
63-
* @param {string=} specialKey The special property name that matches against any property.
63+
* @param {string=} anyPropertyKey The special property name that matches against any property.
6464
* By default `$`.
6565
*
6666
* @example
@@ -133,7 +133,7 @@
133133
*/
134134

135135
function filterFilter() {
136-
return function(array, expression, comparator, specialKey) {
136+
return function(array, expression, comparator, anyPropertyKey) {
137137
if (!isArrayLike(array)) {
138138
if (array == null) {
139139
return array;
@@ -142,7 +142,7 @@ function filterFilter() {
142142
}
143143
}
144144

145-
specialKey = specialKey || '$';
145+
anyPropertyKey = anyPropertyKey || '$';
146146
var expressionType = getTypeForFilter(expression);
147147
var predicateFn;
148148
var matchAgainstAnyProp;
@@ -159,7 +159,7 @@ function filterFilter() {
159159
//jshint -W086
160160
case 'object':
161161
//jshint +W086
162-
predicateFn = createPredicateFn(expression, comparator, specialKey, matchAgainstAnyProp);
162+
predicateFn = createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp);
163163
break;
164164
default:
165165
return array;
@@ -170,8 +170,8 @@ function filterFilter() {
170170
}
171171

172172
// Helper functions for `filterFilter`
173-
function createPredicateFn(expression, comparator, specialKey, matchAgainstAnyProp) {
174-
var shouldMatchPrimitives = isObject(expression) && (specialKey in expression);
173+
function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) {
174+
var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression);
175175
var predicateFn;
176176

177177
if (comparator === true) {
@@ -199,25 +199,25 @@ function createPredicateFn(expression, comparator, specialKey, matchAgainstAnyPr
199199

200200
predicateFn = function(item) {
201201
if (shouldMatchPrimitives && !isObject(item)) {
202-
return deepCompare(item, expression[specialKey], comparator, specialKey, false);
202+
return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false);
203203
}
204-
return deepCompare(item, expression, comparator, specialKey, matchAgainstAnyProp);
204+
return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp);
205205
};
206206

207207
return predicateFn;
208208
}
209209

210-
function deepCompare(actual, expected, comparator, specialKey, matchAgainstAnyProp, dontMatchWholeObject) {
210+
function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) {
211211
var actualType = getTypeForFilter(actual);
212212
var expectedType = getTypeForFilter(expected);
213213

214214
if ((expectedType === 'string') && (expected.charAt(0) === '!')) {
215-
return !deepCompare(actual, expected.substring(1), comparator, specialKey, matchAgainstAnyProp);
215+
return !deepCompare(actual, expected.substring(1), comparator, anyPropertyKey, matchAgainstAnyProp);
216216
} else if (isArray(actual)) {
217217
// In case `actual` is an array, consider it a match
218218
// if ANY of it's items matches `expected`
219219
return actual.some(function(item) {
220-
return deepCompare(item, expected, comparator, specialKey, matchAgainstAnyProp);
220+
return deepCompare(item, expected, comparator, anyPropertyKey, matchAgainstAnyProp);
221221
});
222222
}
223223

@@ -226,21 +226,21 @@ function deepCompare(actual, expected, comparator, specialKey, matchAgainstAnyPr
226226
var key;
227227
if (matchAgainstAnyProp) {
228228
for (key in actual) {
229-
if ((key.charAt(0) !== '$') && deepCompare(actual[key], expected, comparator, specialKey, true)) {
229+
if ((key.charAt(0) !== '$') && deepCompare(actual[key], expected, comparator, anyPropertyKey, true)) {
230230
return true;
231231
}
232232
}
233-
return dontMatchWholeObject ? false : deepCompare(actual, expected, comparator, specialKey, false);
233+
return dontMatchWholeObject ? false : deepCompare(actual, expected, comparator, anyPropertyKey, false);
234234
} else if (expectedType === 'object') {
235235
for (key in expected) {
236236
var expectedVal = expected[key];
237237
if (isFunction(expectedVal) || isUndefined(expectedVal)) {
238238
continue;
239239
}
240240

241-
var matchAnyProperty = key === specialKey;
241+
var matchAnyProperty = key === anyPropertyKey;
242242
var actualVal = matchAnyProperty ? actual : actual[key];
243-
if (!deepCompare(actualVal, expectedVal, comparator, specialKey, matchAnyProperty, matchAnyProperty)) {
243+
if (!deepCompare(actualVal, expectedVal, comparator, anyPropertyKey, matchAnyProperty, matchAnyProperty)) {
244244
return false;
245245
}
246246
}

0 commit comments

Comments
 (0)