MCPcopy
hub / github.com/mongodb/node-mongodb-native / _streamEvents

Method _streamEvents

src/change_stream.ts:958–972  ·  view source on GitHub ↗

@internal

(cursor: ChangeStreamCursor<TSchema, TChange>)

Source from the content-addressed store, hash-verified

956
957 /** @internal */
958 private _streamEvents(cursor: ChangeStreamCursor<TSchema, TChange>): void {
959 this._setIsEmitter();
960 const stream = this.cursorStream ?? cursor.stream();
961 this.cursorStream = stream;
962 stream.on('data', change => {
963 try {
964 const processedChange = this._processChange(change);
965 this.emit(ChangeStream.CHANGE, processedChange);
966 } catch (error) {
967 this.emit(ChangeStream.ERROR, error);
968 }
969 this.timeoutContext?.refresh();
970 });
971 stream.on('error', error => this._processErrorStreamMode(error, this.cursor.id != null));
972 }
973
974 /** @internal */
975 private _endStream(): void {

Callers 2

constructorMethod · 0.95

Calls 7

_setIsEmitterMethod · 0.95
_processChangeMethod · 0.95
streamMethod · 0.80
onMethod · 0.80
emitMethod · 0.65
refreshMethod · 0.45

Tested by

no test coverage detected