summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLV-426 <lv-426@taproot.org.il>2014-12-07 17:26:22 +0200
committerAlon Levy <alon@pobox.com>2014-12-16 10:59:14 +0200
commit36bc1bfde4e93f5b28debc40310ebfd51a194065 (patch)
tree14341881988356366b70518e55d0df87e35ff534 /src
parent33b9504cf7eeb72bac43418f2f5a8d6a6721d1ce (diff)
util.assert
Diffstat (limited to 'src')
-rw-r--r--src/util.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util.js b/src/util.js
index 7d7ebe69..3fd4aecb 100644
--- a/src/util.js
+++ b/src/util.js
@@ -2,6 +2,16 @@
define(function() {
+ function assert(condition, message) {
+ if (false == condition) {
+ message = message || "Assertion failed";
+ if (typeof Error !== "undefined") {
+ throw new Error(message);
+ }
+ throw message; // Fallback
+ }
+ }
+
function set_from_array(a) {
var ret = {};
for (var k = 0; k < a.length; ++k) {
@@ -52,6 +62,7 @@ define(function() {
}
return {
+ assert: assert,
set_from_array: set_from_array,
set_from_object: set_from_object,
set_diff: set_diff,