Const StreamInstanceBase
StreamInstanceBase: StreamInstanceBaseClass = class<Chunk extends string | Buffer, Err = any>implements Stream<Chunk, Err>, StreamEventEmitter<Chunk, Err>, StreamDatabase<Chunk, Err> {readonly #symEvents = new EventEmitter()readonly #symMethodCalls = Array<MethodCall<Chunk, Err>>()readonly #symDataEventTimeout: numberconstructor(options: StreamInstance.ConstructorOptions = {}) {const { dataEventTimeout = 0 } = optionsthis.#symDataEventTimeout = dataEventTimeout}public addListener(event: any, listener: any): void {this.#symEvents.addListener(event, listener)recordListenerModifier(this.#symMethodCalls, MethodName.addListener, event, listener)}public removeListener(event: any, listener: any): void {this.#symEvents.removeListener(event, listener)recordListenerModifier(this.#symMethodCalls, MethodName.removeListener, event, listener)}public on(event: any, listener: any): void {this.#symEvents.on(event, listener)recordListenerModifier(this.#symMethodCalls, MethodName.on, event, listener)}public once(event: any, listener: any): void {this.#symEvents.once(event, listener)recordListenerModifier(this.#symMethodCalls, MethodName.once, event, listener)}public write(chunk: Chunk): void {this.#symMethodCalls.push(new MethodCallInstance.Write(chunk))void this.asyncEmit('data', chunk)}public emit(...args: [any, ...any[]]): void {this.#symEvents.emit(...args)}public asyncEmit(...args: [any, ...any[]]): Promise<void> {return new Promise(resolve =>setTimeout(() => {this.emit(...args)resolve()}, this.#symDataEventTimeout))}public getMethodCalls() {return this.#symMethodCalls}public getChunks() {return this.#symMethodCalls.filter((x): x is MethodCall.Write<Chunk> => x.name === MethodName.write).map(x => x.data)}public async *[Symbol.asyncIterator]() {yield* this.getChunks()}}
StreamInstance
is a subclass ofStreamInstanceBase
which in turn is a wrapper ofEventEmitter