Sha256: c0c349715a670305c661f67e13de3d4f039ed887ac7fad6266228f77c2e2e960
Contents?: true
Size: 694 Bytes
Versions: 356
Compression:
Stored size: 694 Bytes
Contents
/** * Module dependencies. */ var AssertionError = require('assert').AssertionError , callsite = require('callsite') , fs = require('fs') /** * Expose `assert`. */ module.exports = process.env.NO_ASSERT ? function(){} : assert; /** * Assert the given `expr`. */ function assert(expr) { if (expr) return; var stack = callsite(); var call = stack[1]; var file = call.getFileName(); var lineno = call.getLineNumber(); var src = fs.readFileSync(file, 'utf8'); var line = src.split('\n')[lineno-1]; var src = line.match(/assert\((.*)\)/)[1]; var err = new AssertionError({ message: src, stackStartFunction: stack[0].getFunction() }); throw err; }
Version data entries
356 entries across 92 versions & 4 rubygems