Skip to content

Commit

Permalink
Moved isNumber into functions.js
Browse files Browse the repository at this point in the history
  • Loading branch information
meszaros-lajos-gyorgy committed Jan 21, 2022
1 parent f1205c6 commit 98168b8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function isNumber(x) {
if (typeof x === 'number') return true;
if (/^0x[0-9a-f]+$/i.test(x)) {
try {
return Number(x) <= Number.MAX_SAFE_INTEGER;
} catch {
return false;
}
}
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}

module.exports = {
isNumber
};
13 changes: 1 addition & 12 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
const unflatten = require('flat').unflatten;
const flatten = require('flat');

function isNumber(x) {
if (typeof x === 'number') return true;
if (/^0x[0-9a-f]+$/i.test(x)) {
try {
return Number(x) <= Number.MAX_SAFE_INTEGER;
} catch {
return false;
}
}
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}
const { isNumber } = require('./functions.js');

module.exports = function (args, opts) {
if (!opts) opts = {};
Expand Down

0 comments on commit 98168b8

Please sign in to comment.