summaryrefslogtreecommitdiff
path: root/threads.js
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2014-12-07 11:49:14 +0100
committerGubolin <gubolin@fantasymail.de>2014-12-07 11:49:14 +0100
commit80b8581462cb2299f3e776b8052877d47906eeee (patch)
tree9d39bf629d6a8c74944fb34818d80b8909377026 /threads.js
parent124f88969f730104caf3410419bef274fd05e0c0 (diff)
parent18857df3e5094b6518c12ddd632f59a82fca1be6 (diff)
downloadsnap-80b8581462cb2299f3e776b8052877d47906eeee.tar.gz
snap-80b8581462cb2299f3e776b8052877d47906eeee.zip
Merge branch 'issue_458' into development
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 54da3e8..214cb8a 100644
--- a/threads.js
+++ b/threads.js
@@ -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)) {