vigneshshanmugam/elements-kinds

`isDouble` doesn’t actually check for doubles

Opened this issue · 0 comments

isDouble just checks for numbers:

elements-kinds/index.js

Lines 14 to 23 in 2d96ef5

/**
* Handles +-Infinity, Doubles, NaN, -0
*/
function isDouble(arr) {
return arr.every(e => typeof e === "number");
//return arr.some(
// e =>
// Number.isNaN(e) || (Number(e) === e && e % 1 !== 0) || Object.is(e, -0)
// );
}

This appears to work fine because of the ordering used here, where isDouble is only used if it’s not an array of Smis:

elements-kinds/index.js

Lines 46 to 50 in 2d96ef5

if (isSMI(inputArray)) {
kind = ELEMENTS_KINDS.HOLEY_SMI_ELEMENTS;
} else if (isDouble(inputArray)) {
kind = ELEMENTS_KINDS.HOLEY_DOUBLE_ELEMENTS;
} else {

Suggested fix: either rename isDouble to isNumber, or actually check for double values :)