Skip to content

Commit dc47803

Browse files
committed
Filter based on multiple values.
Added functionality to filter the data with multiple value checks. The matched property's value will be checked against all the values passed in using the value config property.
1 parent 0298571 commit dc47803

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

demos/demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
var config = {
111111
property: property.split(","),
112112
wrapper: wrapper,
113-
value: propertyValue,
113+
value: propertyValue.split(","),
114114
checkContains: checkContains,
115115
startsWith: startsWith,
116116
matchCase: matchCase,

demos/home.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@
7979
</tr>
8080
<tr class="input-row">
8181
<td>value</td>
82-
<td>string</td>
83-
<td>""</td>
84-
<td>An optional value passed to be matched with the value of the matched property value.</td>
82+
<td>string/array</td>
83+
<td>[V1...Vn]</td>
84+
<td>An optional value passed in as a string (for a single value match) or as an array to check the matched property value against multiple values.</td>
8585
</tr>
8686
<tr class="input-row">
8787
<td>checkContains</td>

src/filterJSON.plugin.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
};
5858

5959
if(config.value) {
60-
var internalConfig = {},
60+
var valueArray = config.value.length ? config.value : [config.value],
61+
internalConfig = {},
6162
type = Object.prototype.toString.call( j ),
6263
innerComparo = function(type, originalValue, valueToCompare) {
6364
if(type === "[object String]") {
@@ -114,7 +115,9 @@
114115
}
115116
};
116117

117-
innerComparo(type, j, config.value);
118+
for(k in valueArray) {
119+
innerComparo(type, j, valueArray[k]);
120+
}
118121
}
119122
else {
120123
constructReturnObject(json, j);

src/filterJSON.plugin.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)