Skip to content

Commit

Permalink
Merge pull request #23 from SocketDev/fix-old-browsers
Browse files Browse the repository at this point in the history
fix for browsers that don't support ?. syntax
  • Loading branch information
feross authored Jun 22, 2021
2 parents f548bba + 784ee9d commit 43a37d5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/transform-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* result.done is a promise that fulfills or rejects once the stream is done.
* Includes a shim for environments where TransformStream is not available.
*/
export function transformStream (sourceReadable, transformer) {
export function transformStream (sourceReadable, transformer = {}) {
let transformedReadable
let done

Expand Down Expand Up @@ -47,7 +47,7 @@ class TransformStreamSource {
}

async start (controller) {
if (this.transformer?.start) {
if (this.transformer.start) {
try {
await this.transformer.start(controller)
} catch (err) {
Expand All @@ -71,14 +71,14 @@ class TransformStreamSource {
try {
const data = await this.reader.read()
if (data.done) {
if (this.transformer?.flush) {
if (this.transformer.flush) {
await this.transformer.flush(controller)
}
controller.close()
this.resolveDone()
return
}
if (this.transformer?.transform) {
if (this.transformer.transform) {
await this.transformer.transform(data.value, wrappedController)
} else {
wrappedController.enqueue(data.value)
Expand Down

0 comments on commit 43a37d5

Please sign in to comment.