c-style assert() for nodejs, reporting the expression string as the error message
by tjJavaScript
Last 12 weeks · 0 commits
2 of 6 standards met
Repository: tj/better-assert. Description: c-style assert() for nodejs, reporting the expression string as the error message Stars: 288, Forks: 22. Primary language: JavaScript. Languages: JavaScript (95.4%), Makefile (4.6%). License: MIT. Latest release: 1.0.2 (11y ago). Open PRs: 3, open issues: 5. Last activity: 7y ago. Community health: 42%. Top contributors: tj, adohe, conradkleinespel, devinrhode2, ForbesLindesay, kgantsov, mikaturunen, craftzdog.
The callsite returns a line number for compiled code but it's trying to read the line from uncompiled one.
Works for babel 7. Augments #16, fixes #12. See fork https://github.com/GerHobbelt/better-assert for tests including babel transpiled runs. The key problem was when using a modern statement in your code, which is then transpiled by babel, which replaces the calls which something like when you transpile to ES5 or similar old targets, resulting in the line regex in better-assert to crash. See also the pullreqqed code changes and commit message.