New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

array-math

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-math - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

test/testRange.js

21

index.js

@@ -33,3 +33,3 @@ function factors(n) {

function isPrime(n) {
if (n===0)
if (!n)
return false

@@ -43,2 +43,20 @@ n = Math.abs(n)

function range(low, high) {
if (!low) {
low = 0
high = 0
} else if (high && high<low) {
var t = low
low = high
high = t
} else if (!high) {
high = low
low = 0
}
var result = []
for(var i=low; i<high; i++)
result.push(i)
return result
}
function multiply(a) {

@@ -56,4 +74,5 @@ return a.reduce(function (memo, curr) { return memo*curr }, 1)

isPrime: isPrime,
range: range,
multiply: multiply,
sum: sum
}

6

package.json
{
"name": "array-math",
"version": "0.0.4",
"version": "0.0.5",
"main": "./index.js",

@@ -9,3 +9,3 @@ "author": {

},
"description": "Do math on arrays: find divisors or factors of a number, or sum or multiply an array.",
"description": "Do math on arrays: find divisors or factors of a number, sum or multiply an array, and more!",
"keywords": [

@@ -16,2 +16,4 @@ "math",

"divisor",
"prime",
"range",
"sum",

@@ -18,0 +20,0 @@ "multiply"

@@ -12,2 +12,3 @@ array-math

- [aMath.isPrime(n)](https://github.com/ArtskydJ/array-math#amathisprimen)
- [aMath.range(n[, m])](https://github.com/ArtskydJ/array-math#amathrangenm)
- [aMath.multiply(a)](https://github.com/ArtskydJ/array-math#amathmultiplya)

@@ -29,8 +30,5 @@ - [aMath.sum(a)](https://github.com/ArtskydJ/array-math#amathsuma)

aMath.factors(2)
// -> [2]
aMath.factors(96)
// -> [2, 2, 2, 2, 2, 3]
aMath.factors(100)
// -> [2, 2, 5, 5]
aMath.factors(2) // -> [2]
aMath.factors(96) // -> [2, 2, 2, 2, 2, 3]
aMath.factors(100) // -> [2, 2, 5, 5]

@@ -41,8 +39,5 @@ ##aMath.divisors(n)

aMath.divisors(2)
// -> [2]
aMath.divisors(96)
// -> [1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 96]
aMath.divisors(100)
// -> [1, 2, 4, 5, 10, 20, 25, 50, 100]
aMath.divisors(2) // -> [2]
aMath.divisors(96) // -> [1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 96]
aMath.divisors(100) // -> [1, 2, 4, 5, 10, 20, 25, 50, 100]

@@ -53,22 +48,22 @@ ##aMath.isPrime(n)

aMath.isPrime(2)
// -> true
aMath.isPrime(3)
// -> true
aMath.isPrime(4)
// -> false
aMath.isPrime(7)
// -> true
aMath.isPrime(96)
// -> false
aMath.isPrime(97)
// -> true
aMath.isPrime(100)
// -> false
aMath.isPrime(113)
// -> true
aMath.isPrime(117)
// -> false
aMath.isPrime(2) // -> true
aMath.isPrime(3) // -> true
aMath.isPrime(4) // -> false
aMath.isPrime(7) // -> true
aMath.isPrime(96) // -> false
aMath.isPrime(97) // -> true
aMath.isPrime(100) // -> false
aMath.isPrime(113) // -> true
aMath.isPrime(117) // -> false
##aMath.range(n[, m])
aMath.range(0) // -> []
aMath.range(1) // -> [1]
aMath.range(2) // -> [0, 1]
aMath.range(3) // -> [0, 1, 2]
aMath.range(10) // -> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
aMath.range(2, 10) // -> [2, 3, 4, 5, 6, 7, 8, 9]
aMath.range(5, 10) // -> [5, 6, 7, 8, 9]
##aMath.multiply(a)

@@ -78,10 +73,6 @@

aMath.multiply([2, 96, 100])
// -> 19200
aMath.multiply([40, 3, 17])
// -> 2040
aMath.multiply([4, 5, 2, 5.2, 3.8])
// -> 790.4
aMath.multiply([520, 0.2, 0.2, 0.8])
// -> 16.64
aMath.multiply([2, 96, 100]) // -> 19200
aMath.multiply([40, 3, 17]) // -> 2040
aMath.multiply([4, 5, 2, 5.2, 3.8]) // -> 790.4
aMath.multiply([520, 0.2, 0.2, 0.8]) // -> 16.64

@@ -92,8 +83,5 @@ ##aMath.sum(a)

aMath.sum([2, 96, 100])
// -> 198
aMath.sum([2, -96, 100])
// -> 6
aMath.sum([45, 20, 8.3])
// -> 73.3
aMath.sum([2, 96, 100]) // -> 198
aMath.sum([2, -96, 100]) // -> 6
aMath.sum([45, 20, 8.3]) // -> 73.3

@@ -100,0 +88,0 @@ ##License

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