summaryrefslogtreecommitdiff
path: root/cli/js/web/streams/transform_stream_default_controller.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-07-19 19:49:44 +0200
committerGitHub <noreply@github.com>2020-07-19 19:49:44 +0200
commitfa61956f03491101b6ef64423ea2f1f73af26a73 (patch)
treec3800702071ca78aa4dd71bdd0a59a9bbe460bdd /cli/js/web/streams/transform_stream_default_controller.ts
parent53adde866dd399aa2509d14508642fce37afb8f5 (diff)
Port internal TS code to JS (#6793)
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Diffstat (limited to 'cli/js/web/streams/transform_stream_default_controller.ts')
-rw-r--r--cli/js/web/streams/transform_stream_default_controller.ts75
1 files changed, 0 insertions, 75 deletions
diff --git a/cli/js/web/streams/transform_stream_default_controller.ts b/cli/js/web/streams/transform_stream_default_controller.ts
deleted file mode 100644
index 54f1e9f2d..000000000
--- a/cli/js/web/streams/transform_stream_default_controller.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-import {
- FlushAlgorithm,
- isTransformStreamDefaultController,
- readableStreamDefaultControllerGetDesiredSize,
- TransformAlgorithm,
- transformStreamDefaultControllerEnqueue,
- transformStreamDefaultControllerError,
- transformStreamDefaultControllerTerminate,
-} from "./internals.ts";
-import type { ReadableStreamDefaultControllerImpl } from "./readable_stream_default_controller.ts";
-import * as sym from "./symbols.ts";
-import type { TransformStreamImpl } from "./transform_stream.ts";
-import { customInspect } from "../console.ts";
-import { setFunctionName } from "../util.ts";
-
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export class TransformStreamDefaultControllerImpl<I = any, O = any>
- implements TransformStreamDefaultController<O> {
- [sym.controlledTransformStream]: TransformStreamImpl<I, O>;
- [sym.flushAlgorithm]: FlushAlgorithm;
- [sym.transformAlgorithm]: TransformAlgorithm<I>;
-
- private constructor() {
- throw new TypeError(
- "TransformStreamDefaultController's constructor cannot be called.",
- );
- }
-
- get desiredSize(): number | null {
- if (!isTransformStreamDefaultController(this)) {
- throw new TypeError("Invalid TransformStreamDefaultController.");
- }
- const readableController = this[sym.controlledTransformStream][
- sym.readable
- ][sym.readableStreamController];
- return readableStreamDefaultControllerGetDesiredSize(
- readableController as ReadableStreamDefaultControllerImpl<O>,
- );
- }
-
- enqueue(chunk: O): void {
- if (!isTransformStreamDefaultController(this)) {
- throw new TypeError("Invalid TransformStreamDefaultController.");
- }
- transformStreamDefaultControllerEnqueue(this, chunk);
- }
-
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- error(reason?: any): void {
- if (!isTransformStreamDefaultController(this)) {
- throw new TypeError("Invalid TransformStreamDefaultController.");
- }
- transformStreamDefaultControllerError(this, reason);
- }
-
- terminate(): void {
- if (!isTransformStreamDefaultController(this)) {
- throw new TypeError("Invalid TransformStreamDefaultController.");
- }
- transformStreamDefaultControllerTerminate(this);
- }
-
- [customInspect](): string {
- return `${this.constructor.name} { desiredSize: ${
- String(this.desiredSize)
- } }`;
- }
-}
-
-setFunctionName(
- TransformStreamDefaultControllerImpl,
- "TransformStreamDefaultController",
-);