Skip to content

Commit 9b15eed

Browse files
committed
Remove xor and add additional compilation check for division
1 parent 1093c27 commit 9b15eed

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

async.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,7 @@ modes.forEach((logic) => {
304304
'>=': (a, b) => a >= b,
305305
'<=': (a, b) => a <= b,
306306
or: (a, b) => a || b,
307-
and: (a, b) => a && b,
308-
xor: (a, b) => a ^ b
307+
and: (a, b) => a && b
309308
}
310309

311310
await Promise.all(

defaultMethods.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ const defaultMethods = {
243243
}
244244
return true
245245
},
246-
xor: ([a, b]) => a ^ b,
247246
// Why "executeInLoop"? Because if it needs to execute to get an array, I do not want to execute the arguments,
248247
// Both for performance and safety reasons.
249248
or: {
@@ -927,7 +926,7 @@ defaultMethods.if.compile = function (data, buildState) {
927926
* Transforms the operands of the arithmetic operation to numbers.
928927
*/
929928
function numberCoercion (i, buildState) {
930-
if (Array.isArray(i)) return 'precoerceNumber(NaN)'
929+
if (Array.isArray(i)) return precoerceNumber(NaN)
931930

932931
if (typeof i === 'number' || typeof i === 'boolean') return '+' + buildString(i, buildState)
933932
if (typeof i === 'string') return '+' + precoerceNumber(+i)
@@ -971,6 +970,7 @@ defaultMethods['/'].compile = function (data, buildState) {
971970
if (Array.isArray(data)) {
972971
return `(${data.map((i, x) => {
973972
let res = numberCoercion(i, buildState)
973+
if (x && res === '+0') precoerceNumber(NaN)
974974
if (x) res = `precoerceNumber(${res} || NaN)`
975975
return res
976976
}).join(' / ')})`

test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,7 @@ modes.forEach((logic) => {
316316
'>=': (a, b) => a >= b,
317317
'<=': (a, b) => a <= b,
318318
or: (a, b) => a || b,
319-
and: (a, b) => a && b,
320-
xor: (a, b) => a ^ b
319+
and: (a, b) => a && b
321320
}
322321
Object.keys(operators).forEach((i) => {
323322
vectors.forEach((vector) => {

0 commit comments

Comments
 (0)