From 784ee9de98fa3ecf321982541d89c792dbecfc35 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Mon, 21 Jun 2021 19:51:07 -0700 Subject: [PATCH] fix for browsers that don't support ?. syntax --- lib/transform-stream.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/transform-stream.js b/lib/transform-stream.js index 0032c9e..ad63c1a 100644 --- a/lib/transform-stream.js +++ b/lib/transform-stream.js @@ -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 @@ -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) { @@ -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)