Skip to content

Commit a06483e

Browse files
committed
try another way of parsing number
1 parent 252ee01 commit a06483e

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

OpenFlowNodeRED/src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ process.on('unhandledRejection', up => {
3232
console.error(up);
3333
throw up
3434
});
35-
function isNumeric(n) {
36-
return !isNaN(parseFloat(n)) && isFinite(n);
35+
// function isNumeric(n) {
36+
// return !isNaN(parseFloat(n)) && isFinite(n);
37+
// }
38+
function isNumeric(val) {
39+
return Number(parseFloat(val)) === val;
3740
}
3841
(async function (): Promise<void> {
3942
try {
@@ -42,8 +45,9 @@ function isNumeric(n) {
4245

4346
var q: SigninMessage = new SigninMessage();
4447
var user = new TokenUser();
45-
user.name = "nodered" + Config.nodered_id;
46-
if (!isNumeric(Config.nodered_id)) {
48+
if (isNumeric(Config.nodered_id)) {
49+
user.name = "nodered" + Config.nodered_id;
50+
} else {
4751
user.name = Config.nodered_id;
4852
}
4953
user.username = user.name;

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.171
1+
0.0.172

0 commit comments

Comments
 (0)