ml-array-max
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -12,5 +12,9 @@ 'use strict'; | ||
} | ||
if (input.length === 0) { | ||
throw new Error('input must not be empty'); | ||
} | ||
var max = input[0]; | ||
var l = input.length; | ||
for (var i = 1; i < l; i++) { | ||
for (var i = 1; i < input.length; i++) { | ||
if (input[i] > max) max = input[i]; | ||
@@ -17,0 +21,0 @@ } |
{ | ||
"name": "ml-array-max", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Get the maximum value in an array", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -5,12 +5,12 @@ import max from '..'; | ||
it('should return the max', () => { | ||
expect(max([])).toEqual(undefined); | ||
expect(max([0])).toEqual(0); | ||
expect(max([1])).toEqual(1); | ||
expect(max([1, 2])).toEqual(2); | ||
expect(max([1, 2, 1])).toEqual(2); | ||
expect(max([3, 2, 1])).toEqual(3); | ||
expect(max([0])).toBe(0); | ||
expect(max([1])).toBe(1); | ||
expect(max([1, 2])).toBe(2); | ||
expect(max([1, 2, 1])).toBe(2); | ||
expect(max([3, 2, 1])).toBe(3); | ||
}); | ||
it('should throw on invalid value', () => { | ||
expect(() => max()).toThrow(/input must be an array/); | ||
expect(() => max([])).toThrow(/input must not be empty/); | ||
}); | ||
}); |
@@ -10,5 +10,9 @@ /** | ||
} | ||
if (input.length === 0) { | ||
throw new Error('input must not be empty'); | ||
} | ||
var max = input[0]; | ||
var l = input.length; | ||
for (var i = 1; i < l; i++) { | ||
for (var i = 1; i < input.length; i++) { | ||
if (input[i] > max) max = input[i]; | ||
@@ -15,0 +19,0 @@ } |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
3573
52
1