Skip to content

Commit 4ef4d7e

Browse files
author
Cache Hamm
authored
Merge pull request #11 from CacheControl/array-operator-polyfills
convert array operators to use indexOf instead of includes
2 parents be1a0b5 + cc83395 commit 4ef4d7e

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

dist/engine-default-operators.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ Operators.push(new _operator2.default('notEqual', function (a, b) {
1818
return a !== b;
1919
}));
2020
Operators.push(new _operator2.default('in', function (a, b) {
21-
return b.includes(a);
21+
return b.indexOf(a) > -1;
2222
}));
2323
Operators.push(new _operator2.default('notIn', function (a, b) {
24-
return !b.includes(a);
24+
return b.indexOf(a) === -1;
2525
}));
2626

2727
Operators.push(new _operator2.default('contains', function (a, b) {
28-
return a.includes(b);
28+
return a.indexOf(b) > -1;
2929
}, Array.isArray));
3030
Operators.push(new _operator2.default('doesNotContain', function (a, b) {
31-
return !a.includes(b);
31+
return a.indexOf(b) === -1;
3232
}, Array.isArray));
3333

3434
function numberValidator(factValue) {

src/engine-default-operators.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import Operator from './operator'
55
let Operators = []
66
Operators.push(new Operator('equal', (a, b) => a === b))
77
Operators.push(new Operator('notEqual', (a, b) => a !== b))
8-
Operators.push(new Operator('in', (a, b) => b.includes(a)))
9-
Operators.push(new Operator('notIn', (a, b) => !b.includes(a)))
8+
Operators.push(new Operator('in', (a, b) => b.indexOf(a) > -1))
9+
Operators.push(new Operator('notIn', (a, b) => b.indexOf(a) === -1))
1010

11-
Operators.push(new Operator('contains', (a, b) => a.includes(b), Array.isArray))
12-
Operators.push(new Operator('doesNotContain', (a, b) => !a.includes(b), Array.isArray))
11+
Operators.push(new Operator('contains', (a, b) => a.indexOf(b) > -1, Array.isArray))
12+
Operators.push(new Operator('doesNotContain', (a, b) => a.indexOf(b) === -1, Array.isArray))
1313

1414
function numberValidator (factValue) {
1515
return Number.parseFloat(factValue).toString() !== 'NaN'

0 commit comments

Comments
 (0)