isaacs/sax-js — pull request #107 by superjoe30 (2013-07-22 05:29:06+00:00)
Title: parser.pause()

Added support for parser.pause() with the following semantics:

After a parser.pause(), no events should be emitted before the next parser.resume(), even if parser.write() is invoked.

Needed to slightly modify:

parser.write(): to detect pauses and buffer the chunk if parser is paused.
parser.resume(): to resume all the pending buffers that were written while paused.
parser.pause(): to set the pausing state, to be detected in parser.write().
Added test test/pause.js that takes a large xml chunk, breaks it in pieces and:

asserts that no event is emitted while paused.
asserts that the order of all events is as expected.
Documented parser.pause in README.

This is pgte's code from https://github.com/isaacs/sax-js/pull/65 updated
to work with the latest sax-js.