javascript: Stop using longjmp() and friends

Part of #90.

---
Stop using `longjmp()`, which fixes leaks with malformed inputs (and makes the code more readable).