Filter: filter against one or multiple values.
This commit is contained in:
parent
7b5bef86d5
commit
eadf70e994
|
@ -47,20 +47,14 @@ EqualityFilter.prototype.matches = function(target) {
|
||||||
if (typeof(target) !== 'object')
|
if (typeof(target) !== 'object')
|
||||||
throw new TypeError('target (object) required');
|
throw new TypeError('target (object) required');
|
||||||
|
|
||||||
var matches = false;
|
|
||||||
if (target.hasOwnProperty(this.attribute)) {
|
if (target.hasOwnProperty(this.attribute)) {
|
||||||
if (Array.isArray(target[this.attribute])) {
|
var value = this.value;
|
||||||
for (var i = 0; i < target[this.attribute].length; i++) {
|
return Filter.multi_test(
|
||||||
matches = (this.value === target[this.attribute][i]);
|
function(v) { return value === v; },
|
||||||
if (matches)
|
target[this.attribute]);
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
matches = (this.value === target[this.attribute]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,21 +48,14 @@ GreaterThanEqualsFilter.prototype.matches = function(target) {
|
||||||
if (typeof(target) !== 'object')
|
if (typeof(target) !== 'object')
|
||||||
throw new TypeError('target (object) required');
|
throw new TypeError('target (object) required');
|
||||||
|
|
||||||
var matches = false;
|
|
||||||
|
|
||||||
if (target.hasOwnProperty(this.attribute)) {
|
if (target.hasOwnProperty(this.attribute)) {
|
||||||
if (Array.isArray(target[this.attribute])) {
|
var value = this.value;
|
||||||
for (var i = 0; i < target[this.attribute].length; i++) {
|
return Filter.multi_test(
|
||||||
matches = (this.value <= target[this.attribute][i]);
|
function(v) { return value <= v; },
|
||||||
if (matches)
|
target[this.attribute]);
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
matches = (this.value <= target[this.attribute]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,21 +48,14 @@ LessThanEqualsFilter.prototype.matches = function(target) {
|
||||||
if (typeof(target) !== 'object')
|
if (typeof(target) !== 'object')
|
||||||
throw new TypeError('target (object) required');
|
throw new TypeError('target (object) required');
|
||||||
|
|
||||||
var matches = false;
|
|
||||||
if (target.hasOwnProperty(this.attribute)) {
|
if (target.hasOwnProperty(this.attribute)) {
|
||||||
if (Array.isArray(target[this.attribute])) {
|
var value = this.value;
|
||||||
for (var i = 0; i < target[this.attribute].length; i++) {
|
return Filter.multi_test(
|
||||||
matches = (this.value >= target[this.attribute][i]);
|
function(v) { return value >= v; },
|
||||||
if (matches)
|
target[this.attribute]);
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
matches = (this.value >= target[this.attribute]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
return matches;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue