summaryrefslogtreecommitdiff
path: root/threads.js
diff options
context:
space:
mode:
Diffstat (limited to 'threads.js')
-rw-r--r--threads.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/threads.js b/threads.js
index 2b2c1f6..55d3aed 100644
--- a/threads.js
+++ b/threads.js
@@ -118,6 +118,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() {
@@ -1847,13 +1856,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)) {