jsparse
jsparse copied to clipboard
nodejs compatibility
Hi!
I've been enjoying using jsparse, but I wanted to be able to test my parsers in nodejs, and figured it'd also be nice to have the option to put everything within its own namespace, so I hacked up this patch.
I haven't yet updated the examples, but tests.js passes (in 3ms! and ~100ms including startup time and everything), and I added a browser invocation of the tests.js code.
There are two backwards incompatible changes introduced. One is that to use it the old way (with everything in the toplevel namespace) in a browser you must call
jsparse.inject_into(window)
And even with that, memoize must be set on jsparse, it can't be set in the toplevel namespace.
Anyways, thanks for writing jsparse!
Thanks for the pull request, I'll look at it tonight and merge.