Skip to content

Commit

Permalink
Don't throw Error
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Jun 27, 2019
1 parent 3722785 commit f25b47e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/helpers/helpers.math.js
Expand Up @@ -14,10 +14,6 @@ var exports = {
var sqrt = Math.sqrt(value);
var i;

if (!Number.isInteger(value) || value <= 0) {
throw new Error('_factorize expects a positive integer, but received ' + value);
}

for (i = 1; i < sqrt; i++) {
if (value % i === 0) {
result.push(i);
Expand Down
9 changes: 3 additions & 6 deletions test/specs/helpers.math.tests.js
Expand Up @@ -10,11 +10,8 @@ describe('Chart.helpers.math', function() {
expect(factorize(24)).toEqual([1, 2, 3, 4, 6, 8, 12]);
expect(factorize(12)).toEqual([1, 2, 3, 4, 6]);
expect(factorize(4)).toEqual([1, 2]);
expect(function() {
factorize(-1);
}).toThrow(new Error('_factorize expects a positive integer, but received -1'));
expect(function() {
factorize(2.76);
}).toThrow(new Error('_factorize expects a positive integer, but received 2.76'));
expect(factorize(4)).toEqual([1, 2]);
expect(factorize(-1)).toEqual([]);
expect(factorize(2.76)).toEqual([]);
});
});

0 comments on commit f25b47e

Please sign in to comment.