Skip to content

Instantly share code, notes, and snippets.

@catb0t
Last active February 27, 2016 22:58
Show Gist options
  • Save catb0t/dc8d8b3b50a930e72588 to your computer and use it in GitHub Desktop.
Save catb0t/dc8d8b3b50a930e72588 to your computer and use it in GitHub Desktop.
var Assert = function () {
"use strict";
var AssertionError = function (msg) {
var final = "Assertion failed: " + msg;
console.error(final);
};
var args = arguments;
var res = true;
for(var i = 0; i < args.length; i++) {
var d = ((i - 1) < 0) ? 0 : i - 1;
res = (args[i] === args[d]);
if(!res || typeof res === "undefined" || res === null || res !== res) {
throw new AssertionError(args[i] + " != " + args[d]);
}
}
var atn = "not_undefined";
try {
atn = assert(res);
} catch (e) {
if(e instanceof ReferenceError) {
return true;
}
}
if(typeof atn === "undefined") {
return true;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment