MCPcopy Index your code
hub / github.com/stemkoski/stemkoski.github.com / emitDataEvents

Function emitDataEvents

MathBox/mathbox-bundle.js:50353–50400  ·  view source on GitHub ↗
(stream, startPaused)

Source from the content-addressed store, hash-verified

50351};
50352
50353function emitDataEvents(stream, startPaused) {
50354 var state = stream._readableState;
50355
50356 if (state.flowing) {
50357 // https://github.com/isaacs/readable-stream/issues/16
50358 throw new Error('Cannot switch to old mode now.');
50359 }
50360
50361 var paused = startPaused || false;
50362 var readable = false;
50363
50364 // convert to an old-style stream.
50365 stream.readable = true;
50366 stream.pipe = Stream.prototype.pipe;
50367 stream.on = stream.addListener = Stream.prototype.on;
50368
50369 stream.on('readable', function() {
50370 readable = true;
50371
50372 var c;
50373 while (!paused && (null !== (c = stream.read())))
50374 stream.emit('data', c);
50375
50376 if (c === null) {
50377 readable = false;
50378 stream._readableState.needReadable = true;
50379 }
50380 });
50381
50382 stream.pause = function() {
50383 paused = true;
50384 this.emit('pause');
50385 };
50386
50387 stream.resume = function() {
50388 paused = false;
50389 if (readable)
50390 setImmediate(function() {
50391 stream.emit('readable');
50392 });
50393 else
50394 this.read(0);
50395 this.emit('resume');
50396 };
50397
50398 // now make it start, just in case it hadn't already.
50399 stream.emit('readable');
50400}
50401
50402// wrap an old-style stream as the async data source.
50403// This is *not* part of the readable stream interface.

Callers 2

flowFunction · 0.70
mathbox-bundle.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected