I am using the assert module in node.js https://www.npmjs.com/package/assert
In C/C++, one can easily enable/disable assert statements with macros. Can the same thing be done for node.js and javascript in general?
Note that the package you are using is adding asserts as a module and are therefor polyfills.
You can simply overwrite -part- of the Object to disable the polyfill.
Example:
Let's say that you want to disable the deepEqual
assert that currently looks like this:
assert.deepEqual = function deepEqual(actual, expected, message) {
if (!_deepEqual(actual, expected)) {
fail(actual, expected, message, 'deepEqual', assert.deepEqual);
}
};
You can simply overwrite it by doing something like:
assert.deepEqual = function deepEqual(actual, expected, message) {
// disable
};
FYI:
Assert statements are in progress: http://wiki.ecmascript.org/doku.php?id=strawman:assert
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With