diff options
| author | Gubolin <gubolin@fantasymail.de> | 2014-12-07 11:49:14 +0100 |
|---|---|---|
| committer | Gubolin <gubolin@fantasymail.de> | 2014-12-07 11:49:14 +0100 |
| commit | 80b8581462cb2299f3e776b8052877d47906eeee (patch) | |
| tree | 9d39bf629d6a8c74944fb34818d80b8909377026 /threads.js | |
| parent | 124f88969f730104caf3410419bef274fd05e0c0 (diff) | |
| parent | 18857df3e5094b6518c12ddd632f59a82fca1be6 (diff) | |
| download | snap-80b8581462cb2299f3e776b8052877d47906eeee.tar.gz snap-80b8581462cb2299f3e776b8052877d47906eeee.zip | |
Merge branch 'issue_458' into development
Diffstat (limited to 'threads.js')
| -rw-r--r-- | threads.js | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -128,6 +128,15 @@ function snapEquals(a, b) { return x === y; } +// stricter alternative to parseFloat +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat/ +function filterFloat(value) { + if(/^(\-|\+)?([0-9]+(\.[0-9]+)?|Infinity)$/ + .test(value)) + return Number(value); + return NaN; +} + // ThreadManager /////////////////////////////////////////////////////// function ThreadManager() { @@ -1938,13 +1947,14 @@ Process.prototype.reportIsA = function (thing, typeString) { Process.prototype.reportTypeOf = function (thing) { // answer a string denoting the argument's type var exp; + if (thing === null || (thing === undefined)) { return 'nothing'; } if (thing === true || (thing === false)) { return 'Boolean'; } - if (!isNaN(parseFloat(thing))) { + if (!isNaN(filterFloat(thing))) { return 'number'; } if (isString(thing)) { |
