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

Commit a543eda

Browse files
committedMar 30, 2015
refactor(filterFilter): introduce helper function for "DRYness"
1 parent bd25dd7 commit a543eda

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
 

‎src/ng/filter/filter.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function filterFilter() {
135135
}
136136
}
137137

138-
var expressionType = (expression !== null) ? typeof expression : 'null';
138+
var expressionType = getTypeForFilter(expression);
139139
var predicateFn;
140140
var matchAgainstAnyProp;
141141

@@ -204,8 +204,8 @@ function createPredicateFn(expression, comparator, matchAgainstAnyProp) {
204204
}
205205

206206
function deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject) {
207-
var actualType = (actual !== null) ? typeof actual : 'null';
208-
var expectedType = (expected !== null) ? typeof expected : 'null';
207+
var actualType = getTypeForFilter(actual);
208+
var expectedType = getTypeForFilter(expected);
209209

210210
if ((expectedType === 'string') && (expected.charAt(0) === '!')) {
211211
return !deepCompare(actual, expected.substring(1), comparator, matchAgainstAnyProp);
@@ -251,3 +251,8 @@ function deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatc
251251
return comparator(actual, expected);
252252
}
253253
}
254+
255+
// Used for easily differentiating between `null` and actual `object`
256+
function getTypeForFilter(val) {
257+
return (val === null) ? 'null' : typeof val;
258+
}

0 commit comments

Comments
 (0)