assert() that won't expload when not in 'dev' mode

This commit is contained in:
Bryan Ashby 2016-08-26 21:29:49 -06:00
parent 3bae109537
commit 6fa19f9ac3
1 changed files with 18 additions and 0 deletions

18
core/enigma_assert.js Normal file
View File

@ -0,0 +1,18 @@
/* jslint node: true */
'use strict';
// ENiGMA½
const Config = require('./config.js').config;
const Log = require('./logger.js').log;
// deps
const assert = require('assert');
module.exports = function(condition, message) {
if(Config.debug.assertsEnabled) {
assert.apply(this, arguments);
} else if(!(condition)) {
const stack = new Error().stack;
Log.error( { condition : condition, stack : stack }, message || 'Assertion failed' );
}
};