Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quick-is-prime

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quick-is-prime - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

2

package.json
{
"name": "quick-is-prime",
"version": "1.0.6",
"version": "1.0.7",
"description": "Test if a number is prime in constant time, using a cached Sieve of Eratosthenes.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -23,10 +23,10 @@ # quick-is-prime

// Simple examples
console.log(isPrime(47)); // true
console.log(isPrime(48)); // false
console.log(isPrime(61)); // true
console.log(isPrime(100)); // false
isPrime(47) // => true
isPrime(48) // => false
isPrime(61) // => true
isPrime(100) // => false
// More challenging examples
console.log(isPrime(9998903)) // true, takes 1.5 seconds
console.log(isPrime(9893899)) // true, takes less than a millisecond
isPrime(9998903) // => true, takes 1.5 seconds
isPrime(9893899) // => true, takes less than a millisecond
```

@@ -33,0 +33,0 @@

@@ -17,7 +17,10 @@ /*global describe,it*/

it('works for larger numbers too', function () {
it('can test a 7-digit numbers in under two seconds', function () {
var start = process.hrtime();
assert(isPrime(9998903) === true);
var durationInNanoseconds = process.hrtime(start)[1];
assert(durationInNanoseconds < 2000000000);
});
it('takes less than a millisecond to test numbers less than the highest already tested', function () {
it('takes under a millisecond for numbers less than the highest already tested', function () {
var start = process.hrtime();

@@ -28,2 +31,13 @@ assert(isPrime(9893899) === true);

});
it('returns false for 0, 1, and negative numbers', function () {
assert(isPrime(0) === false);
assert(isPrime(1) === false);
assert(isPrime(-3) === false);
});
it('returns false for strings', function () {
assert(isPrime('hello') === false);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc