From fe4ddc09b9192e497e8caf03540b574ba6d4a720 Mon Sep 17 00:00:00 2001 From: Adam Rice Date: Wed, 11 Oct 2017 00:04:09 +0900 Subject: [PATCH] Move TransformStreamDefaultControllerTerminate down Return TransformStreamDefaultController abstract ops to alphabetical order by moving Terminate down. Also put the terminate() method in last-place in the class definition to improve alphabetisation and make it clear that it is less important. --- .../lib/transform-stream.js | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/reference-implementation/lib/transform-stream.js b/reference-implementation/lib/transform-stream.js index 41c3bf1c3..09bc217ae 100644 --- a/reference-implementation/lib/transform-stream.js +++ b/reference-implementation/lib/transform-stream.js @@ -154,20 +154,20 @@ class TransformStreamDefaultController { TransformStreamDefaultControllerEnqueue(this, chunk); } - terminate() { + error(reason) { if (IsTransformStreamDefaultController(this) === false) { - throw defaultControllerBrandCheckException('close'); + throw defaultControllerBrandCheckException('error'); } - TransformStreamDefaultControllerTerminate(this); + TransformStreamDefaultControllerError(this, reason); } - error(reason) { + terminate() { if (IsTransformStreamDefaultController(this) === false) { - throw defaultControllerBrandCheckException('error'); + throw defaultControllerBrandCheckException('close'); } - TransformStreamDefaultControllerError(this, reason); + TransformStreamDefaultControllerTerminate(this); } } @@ -185,24 +185,6 @@ function IsTransformStreamDefaultController(x) { return true; } -function TransformStreamDefaultControllerTerminate(controller) { - verbose('TransformStreamDefaultControllerTerminate()'); - - const stream = controller._controlledTransformStream; - const readableController = stream._readable._readableStreamController; - - if (ReadableStreamDefaultControllerCanCloseOrEnqueue(readableController) === true) { - ReadableStreamDefaultControllerClose(readableController); - } - - WritableStreamDefaultControllerErrorIfNeeded(stream._writable._writableStreamController, - new TypeError('TransformStream terminated')); - if (stream._backpressure === true) { - // Permit any pending write() or start() calls to complete. - TransformStreamSetBackpressure(stream, false); - } -} - function TransformStreamDefaultControllerEnqueue(controller, chunk) { verbose('TransformStreamDefaultControllerEnqueue()'); @@ -237,6 +219,24 @@ function TransformStreamDefaultControllerError(controller, e) { TransformStreamError(stream, e); } +function TransformStreamDefaultControllerTerminate(controller) { + verbose('TransformStreamDefaultControllerTerminate()'); + + const stream = controller._controlledTransformStream; + const readableController = stream._readable._readableStreamController; + + if (ReadableStreamDefaultControllerCanCloseOrEnqueue(readableController) === true) { + ReadableStreamDefaultControllerClose(readableController); + } + + WritableStreamDefaultControllerErrorIfNeeded(stream._writable._writableStreamController, + new TypeError('TransformStream terminated')); + if (stream._backpressure === true) { + // Permit any pending write() or start() calls to complete. + TransformStreamSetBackpressure(stream, false); + } +} + // Class TransformStreamDefaultSink class TransformStreamDefaultSink {