Well worth a quick trip to the source to see how it's implemented. After all, how would the author get around to packaging 4B if statements, like the OP?
He could package it to the size limit and range the numbers it could detect. Add a note to download particular package if the number is out of range of the package and that package is not installed.
One package should probably handle range of one million. Now it's just 4000 packages to install. You wouldn't even notice that in an average js project.
https://www.npmjs.com/package/is-even