Skip to content

Commit

Permalink
feat: emit close and finish events and remove listeners on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 19, 2020
1 parent 82dac22 commit cc42554
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src.runtime/node/stream/readable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class Readable extends EventEmitter implements stream.Readable {
}

_destroy (_error?: any, _callback?: Callback<any>) {
this.removeAllListeners()
}

destroy (error?: Error) {
Expand Down
3 changes: 3 additions & 0 deletions src.runtime/node/stream/writable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export class Writable extends EventEmitter implements stream.Writable {
}
this.writableEnded = true
this.writableFinished = true
this.emit('close')
this.emit('finish')
}

cork (): void {
Expand All @@ -73,5 +75,6 @@ export class Writable extends EventEmitter implements stream.Writable {
}

destroy (_error?: Error): void {
this.removeAllListeners()
}
}

0 comments on commit cc42554

Please sign in to comment.