better-assert icon indicating copy to clipboard operation
better-assert copied to clipboard

Error when importing using a different name than "assert"

Open thevtm opened this issue 6 years ago • 1 comments

Basically if you name the assert function other than "assert" the regex fails.

const betterAss = require("./index");
betterAss(1 === 2);
~/better-assert/index.js:30
  var src = line.match(/assert\((.*)\)/)[1];
                                        ^

TypeError: Cannot read property '1' of null
    at assert (~/better-assert/index.js:30:41)
    at Object.<anonymous> (~/better-assert/fn-name-test.js:4:1)

thevtm avatar Mar 11 '18 12:03 thevtm

+1

ainthek avatar Dec 02 '18 15:12 ainthek