Skip to content

feat(micro-utilities): add validate.io-integer-array to replacements - #1237

Merged
43081j merged 2 commits into
e18e:mainfrom
maksimgm:feat/validate-io-integer-array
Nov 20, 2026
Merged

43081j merged 2 commits into
e18e:mainfrom
maksimgm:feat/validate-io-integer-array

Conversation

@maksimgm

Copy link
Copy Markdown
Contributor

Closes #1206

Adds validate.io-integer-array (~3.2M weekly downloads) to the micro-utilities manifest, with a new snippet::is-integer-array:

const isIntegerArray = (value) =>
  Array.isArray(value) && value.length > 0 && [...value].every(Number.isInteger)

This is close to the snippet in the issue, with one change: the array is spread before calling every. every skips empty slots, so Array(3).every(Number.isInteger) is true, but the package returns false for arrays with holes. Spreading turns holes into undefined, which keeps that behaviour.

I compared it against validate.io-integer-array@1.0.0 on 20,000 random inputs (integers, floats, NaN, ±Infinity, -0, 1e21, strings, booleans, null, BigInt, nested arrays, sparse arrays and non-array values). Every case matched.

The only difference I found is boxed numbers: the package accepts [new Number(3)], while Number.isInteger rejects it.

@43081j
43081j merged commit bf761b1 into e18e:main Nov 20, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Replacement]: validate.io-integer-array

2 participants