@@ -91,26 +91,18 @@ function rangeMatch(key, value, options) {
9191function includesMatch ( key , value ) {
9292 let expressions = [ ] ;
9393
94- // the array includes ONE OE MORE of the provided values
95- if ( value . includes ) {
96- if ( Array . isArray ( value . includes ) ) {
97- let arr = '[' + value . includes . map ( maybeQuote ) . join ( ',' ) + ']' ;
98- expressions . push ( `${ arr } .some(function(v) { return ${ lookUp ( key ) } .indexOf(v) > -1 })` ) ;
99- }
100- else {
101- expressions . push ( `${ lookUp ( key ) } .indexOf(${ maybeQuote ( value . includes ) } ) > -1` ) ;
102- }
94+ // the array includes ONE OE MORE of the provided values (a single value is converted to an array)
95+ if ( value . includes_any ) {
96+ const vals = Array . isArray ( value . includes_any ) ? value . includes_any : [ value . includes_any ] ;
97+ const arr = '[' + vals . map ( maybeQuote ) . join ( ',' ) + ']' ;
98+ expressions . push ( `${ arr } .some(function(v) { return ${ lookUp ( key ) } .indexOf(v) > -1 })` ) ;
10399 }
104100
105- // the array includes ALL of the provided values
101+ // the array includes ALL of the provided values (a single value is converted to an array)
106102 if ( value . includes_all ) {
107- if ( Array . isArray ( value . includes_all ) ) {
108- let arr = '[' + value . includes_all . map ( maybeQuote ) . join ( ',' ) + ']' ;
109- expressions . push ( `${ arr } .every(function(v) { return ${ lookUp ( key ) } .indexOf(v) > -1 })` ) ;
110- }
111- else {
112- expressions . push ( `${ lookUp ( key ) } .indexOf(${ maybeQuote ( value . includes_all ) } ) > -1` ) ;
113- }
103+ const vals = Array . isArray ( value . includes_all ) ? value . includes_all : [ value . includes_all ] ;
104+ const arr = '[' + vals . map ( maybeQuote ) . join ( ',' ) + ']' ;
105+ expressions . push ( `${ arr } .every(function(v) { return ${ lookUp ( key ) } .indexOf(v) > -1 })` ) ;
114106 }
115107
116108 return wrap ( expressions . join ( ' && ' ) ) ;
@@ -157,7 +149,7 @@ function parseFilter(filter, options) {
157149 if ( value . max || value . min ) {
158150 filterAST . push ( rangeMatch ( key , value , options ) ) ;
159151 }
160- else if ( value . includes || value . includes_all ) {
152+ else if ( value . includes_any || value . includes_all ) {
161153 filterAST . push ( includesMatch ( key , value , options ) ) ;
162154 }
163155 } else if ( value == null ) {
0 commit comments