aboutsummaryrefslogtreecommitdiff
path: root/src/utility.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-12-02 13:37:24 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-12-02 13:37:24 -0800
commitd2b0d9924aa9a3603b0b16bd957832faf503c32d (patch)
treedf1b2431d5c2a67756891cbfcc949da524791dc2 /src/utility.js
parent12e85d4ab3fb0447d60165c6ca00296ae0fce9ce (diff)
various fixes from js strict mode testing
Diffstat (limited to 'src/utility.js')
-rw-r--r--src/utility.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/utility.js b/src/utility.js
index e49776d8..1ebbe526 100644
--- a/src/utility.js
+++ b/src/utility.js
@@ -1,3 +1,5 @@
+//"use strict";
+
// General JS utilities - things that might be useful in any JS project.
// Nothing specific to Emscripten appears here.
@@ -61,7 +63,7 @@ function assertTrue(a, msg) {
throw msg;
}
}
-assert = assertTrue;
+var assert = assertTrue;
function warn(a, msg) {
if (!msg) {
@@ -111,13 +113,13 @@ function zeros(size) {
function keys(x) {
var ret = [];
- for (a in x) ret.push(a);
+ for (var a in x) ret.push(a);
return ret;
}
function values(x) {
var ret = [];
- for (a in x) ret.push(x[a]);
+ for (var a in x) ret.push(x[a]);
return ret;
}
@@ -159,7 +161,7 @@ function splitter(array, filter) {
function dcheck(tag) {
return DEBUG_TAGS_SHOWING.indexOf(arguments[0]) != -1;
}
-DPRINT_INDENT = '';
+var DPRINT_INDENT = '';
function dprint_indent() {
DPRINT_INDENT += ' ';
}
@@ -182,8 +184,8 @@ function dprint() {
print(text);
}
-PROF_ORIGIN = Date.now();
-PROF_TIME = PROF_ORIGIN;
+var PROF_ORIGIN = Date.now();
+var PROF_TIME = PROF_ORIGIN;
function PROF(pass) {
if (!pass) {
dprint("Profiling: " + ((Date.now() - PROF_TIME)/1000) + ' seconds, total: ' + ((Date.now() - PROF_ORIGIN)/1000));
@@ -294,3 +296,8 @@ function stringifyWithFunctions(obj) {
}
}
+function sleep(secs) {
+ var start = Date.now();
+ while (Date.now() - start < secs*1000) {};
+}
+