mirror of
https://github.com/denoland/deno.git
synced 2024-12-27 01:29:14 -05:00
82aabb657a
This commit adds a "--no-check" option to following subcommands: - "deno cache" - "deno info" - "deno run" - "deno test" The "--no-check" options allows to skip type checking step and instead directly transpiles TS sources to JS sources. This solution uses `ts.transpileModule()` API and is just an interim solution before implementing it fully in Rust.
75 lines
2.4 KiB
TypeScript
75 lines
2.4 KiB
TypeScript
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import {
|
|
FlushAlgorithm,
|
|
isTransformStreamDefaultController,
|
|
readableStreamDefaultControllerGetDesiredSize,
|
|
setFunctionName,
|
|
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";
|
|
|
|
// 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"
|
|
);
|