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.
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import {
|
|
AbortAlgorithm,
|
|
CloseAlgorithm,
|
|
isWritableStreamDefaultController,
|
|
Pair,
|
|
resetQueue,
|
|
setFunctionName,
|
|
SizeAlgorithm,
|
|
WriteAlgorithm,
|
|
writableStreamDefaultControllerClearAlgorithms,
|
|
writableStreamDefaultControllerError,
|
|
} from "./internals.ts";
|
|
import * as sym from "./symbols.ts";
|
|
import type { WritableStreamImpl } from "./writable_stream.ts";
|
|
import { customInspect } from "../console.ts";
|
|
|
|
export class WritableStreamDefaultControllerImpl<W>
|
|
implements WritableStreamDefaultController {
|
|
[sym.abortAlgorithm]: AbortAlgorithm;
|
|
[sym.closeAlgorithm]: CloseAlgorithm;
|
|
[sym.controlledWritableStream]: WritableStreamImpl;
|
|
[sym.queue]: Array<Pair<{ chunk: W } | "close">>;
|
|
[sym.queueTotalSize]: number;
|
|
[sym.started]: boolean;
|
|
[sym.strategyHWM]: number;
|
|
[sym.strategySizeAlgorithm]: SizeAlgorithm<W>;
|
|
[sym.writeAlgorithm]: WriteAlgorithm<W>;
|
|
|
|
private constructor() {
|
|
throw new TypeError(
|
|
"WritableStreamDefaultController's constructor cannot be called."
|
|
);
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
error(e: any): void {
|
|
if (!isWritableStreamDefaultController(this)) {
|
|
throw new TypeError("Invalid WritableStreamDefaultController.");
|
|
}
|
|
const state = this[sym.controlledWritableStream][sym.state];
|
|
if (state !== "writable") {
|
|
return;
|
|
}
|
|
writableStreamDefaultControllerError(this, e);
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
[sym.abortSteps](reason: any): PromiseLike<void> {
|
|
const result = this[sym.abortAlgorithm](reason);
|
|
writableStreamDefaultControllerClearAlgorithms(this);
|
|
return result;
|
|
}
|
|
|
|
[sym.errorSteps](): void {
|
|
resetQueue(this);
|
|
}
|
|
|
|
[customInspect](): string {
|
|
return `${this.constructor.name} { }`;
|
|
}
|
|
}
|
|
|
|
setFunctionName(
|
|
WritableStreamDefaultControllerImpl,
|
|
"WritableStreamDefaultController"
|
|
);
|