array-normalize
Advanced tools
Comparing version 1.0.0 to 1.0.1
14
index.js
@@ -16,7 +16,17 @@ 'use strict' | ||
if (max === Infinity || min === -Infinity) { | ||
if (max === Infinity && min === -Infinity) { | ||
for (let i = 0, l = arr.length; i < l; i++) { | ||
arr[i] = arr[i] === min ? min : arr[i] === max ? max : 0; | ||
arr[i] = arr[i] === max ? 1 : arr[i] === min ? 0 : .5 | ||
} | ||
} | ||
else if (max === Infinity) { | ||
for (let i = 0, l = arr.length; i < l; i++) { | ||
arr[i] = arr[i] === max ? 1 : 0 | ||
} | ||
} | ||
else if (min === -Infinity) { | ||
for (let i = 0, l = arr.length; i < l; i++) { | ||
arr[i] = arr[i] === min ? 0 : 1 | ||
} | ||
} | ||
else { | ||
@@ -23,0 +33,0 @@ for (let i = 0, l = arr.length; i < l; i++) { |
{ | ||
"name": "array-normalize", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Normalize array to zero mean and unit variance", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,3 +5,3 @@ const norm = require('./') | ||
let a = [-Infinity, -1, 0, 1, Infinity] | ||
assert.deepEqual(norm(a.slice()), [-Infinity, 0, 0, 0, Infinity]) | ||
assert.deepEqual(norm(a.slice()), [0, 0.5, 0.5, 0.5, 1]) | ||
@@ -8,0 +8,0 @@ let b = [0, .5, 1] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2085
40