diff --git a/src/helpers.js b/src/helpers.js index d1cddd3..93a5498 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -574,7 +574,7 @@ export function splice(array, startIndex, nb, ...elements) { nb = array.length - startIndex; else if (nb === null) nb = 0; - else if (Number.isNaN(Number.parseInt(nb))) + else if (Number.isNaN(Number.parseInt(nb, 10))) throw new Error(`argument nb ${nb} can not be parsed into a number!`); nb = Math.max(0, nb); diff --git a/src/type.js b/src/type.js index 98b8978..1891521 100644 --- a/src/type.js +++ b/src/type.js @@ -114,7 +114,7 @@ type.primitive = function(target) { type.splicer = function(target) { if (!type.array(target) || target.length < 1) return false; - if(target.length > 1 && Number.isNaN(Number.parseInt(target[1]))) + if (target.length > 1 && Number.isNaN(Number.parseInt(target[1], 10))) return false; return anyOf(target[0], ['number', 'function', 'object']); diff --git a/test/suites/helpers.js b/test/suites/helpers.js index 8c1e16d..fa476ed 100644 --- a/test/suites/helpers.js +++ b/test/suites/helpers.js @@ -238,11 +238,11 @@ describe('Helpers', function() { it('should throw an error when supplying an argument for nb (deleteCount) which is not parseable as number', function () { const array = [0, 1, 2, 3, 4]; - assert.throws(function () { - splice(array, 2, "a"); + assert.throws(function() { + splice(array, 2, 'a'); }, Error); - assert.throws(function () { + assert.throws(function() { splice(array, 2, {}); }, Error); });