Repository navigation
v2.0.0
Why a new major release
antiprime 1.x gives wrong answers for some inputs and is too slow to use beyond small numbers. The fixes change behaviour that 1.x users may rely on, so they ship together as a major version instead of being slipped into a 1.x patch. This is also the first release since 2020, so the packaging has been modernised at the same time.
Wrong answers fixed
| Call | 1.x | 2.0 |
|---|---|---|
isAntiprime(1.5) |
true |
throws RangeError |
factors(0) |
[0] |
throws RangeError |
primeFactors(1) |
[{ factor: 2, exponent: 0 }] |
[] |
nextPrime(NaN) |
never returns | throws RangeError |
new Antiprime(1).previousAntiprime() |
unrelated TypeError |
RangeError: 1 is the smallest antiprime |
Invalid input now fails the same way in every function: zero, NaN, infinite and out-of-range numbers throw a RangeError, and a pf argument must be the prime factorisation of n.
Much faster
Antiprime checks only look at numbers that could be antiprimes, instead of testing every number below n. new Antiprime(55440).nextAntiprime() took about 4 seconds in 1.0.6 and now takes under a millisecond. Answers come back in milliseconds even near Number.MAX_SAFE_INTEGER.
Modern packaging
- ES modules and CommonJS, with TypeScript types, through an
exportsmap. - Node.js 22 or later.
- Published from GitHub Actions with npm provenance.
New
factorCountgetter onAntiprime.- The
PrimeFactortype is exported. - An API reference with an example for every export.
Upgrading
Most code keeps working. You may need changes if you import from inside the package (antiprime/lib/...), run Node.js older than 22, depend on the lenient 1.x input handling, or call Antiprime methods detached from their instance. See Migrating from 1.x and the changelog for the full list.
1.x will be marked deprecated on npm.
The PR was merged on 1 November and there are no releases yet. If you'd like, I can create v2.0.0 as a draft release with these notes. A draft doesn't start the npm publish; that only happens when you click Publish. Do the one-time npmjs.com and GitHub setup in docs/releasing.md before publishing.