From 565bab2aae11832809ed2fd421568b4e68b0d726 Mon Sep 17 00:00:00 2001 From: v1rtl Date: Tue, 30 Jul 2024 17:01:33 +0300 Subject: [PATCH 1/3] fix: replace is-number dep with a one-liner --- index.js | 2 +- package.json | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/index.js b/index.js index 77fbace..4a89666 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ 'use strict'; -const isNumber = require('is-number'); +const isNumber = (v) => typeof v === "number" || (typeof v === "string" && Number.isFinite(+v)) const toRegexRange = (min, max, options) => { if (isNumber(min) === false) { diff --git a/package.json b/package.json index 4ef194f..211dded 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,6 @@ "scripts": { "test": "mocha" }, - "dependencies": { - "is-number": "^7.0.0" - }, "devDependencies": { "fill-range": "^6.0.0", "gulp-format-md": "^2.0.0", From a452a10915fc1eb6c448f3a6385722015a15b68a Mon Sep 17 00:00:00 2001 From: v1rtl Date: Tue, 30 Jul 2024 17:36:02 +0300 Subject: [PATCH 2/3] add handling for "" --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 4a89666..201eceb 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ 'use strict'; -const isNumber = (v) => typeof v === "number" || (typeof v === "string" && Number.isFinite(+v)) +const isNumber = (v) => typeof v === "number" || (typeof v === "string" && Number.isFinite(+v) && v.trim() !== ""); const toRegexRange = (min, max, options) => { if (isNumber(min) === false) { From 22d1f3e0e28b902429ecfa86a72efe6b1fb28f89 Mon Sep 17 00:00:00 2001 From: v1rtl Date: Tue, 30 Jul 2024 16:05:20 +0000 Subject: [PATCH 3/3] Update index.js Co-authored-by: Sam Martin --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 201eceb..c8071cc 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ 'use strict'; -const isNumber = (v) => typeof v === "number" || (typeof v === "string" && Number.isFinite(+v) && v.trim() !== ""); +const isNumber = (v) => (typeof v === "number" && v - v === 0) || (typeof v === "string" && Number.isFinite(+v) && v.trim() !== ""); const toRegexRange = (min, max, options) => { if (isNumber(min) === false) {