bahmutov / lazy-ass

Lazy node assertions without performance penalty
http://glebbahmutov.com/lazy-ass/
MIT License
68 stars 5 forks source link

if condition is a function, evaluate it #2

Closed bahmutov closed 10 years ago

bahmutov commented 10 years ago

And add the source for the function (if short) to the messages

lazyAss(function () { return 2 + 2 === 5}, 'checking math');
// inside lazyAss
if (typeof arguments[0] === 'function') {
 if (!arguments[0]()) {
   var msg = arguments[0].toString() + ' ' ... the rest of arguments