mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
add notImplemented and unreachable util functions (#540)
This commit is contained in:
parent
aaabc853e8
commit
66f0e93b4c
4 changed files with 16 additions and 7 deletions
|
@ -4,7 +4,8 @@ import {
|
|||
log,
|
||||
createResolvable,
|
||||
Resolvable,
|
||||
typedArrayToArrayBuffer
|
||||
typedArrayToArrayBuffer,
|
||||
notImplemented,
|
||||
} from "./util";
|
||||
import { pubInternal, sub } from "./dispatch";
|
||||
import { deno as pb } from "./msg.pb";
|
||||
|
@ -46,11 +47,11 @@ class FetchResponse implements Response {
|
|||
}
|
||||
|
||||
blob(): Promise<Blob> {
|
||||
throw Error("not implemented");
|
||||
notImplemented();
|
||||
}
|
||||
|
||||
formData(): Promise<FormData> {
|
||||
throw Error("not implemented");
|
||||
notImplemented();
|
||||
}
|
||||
|
||||
async json(): Promise<object> {
|
||||
|
@ -69,7 +70,7 @@ class FetchResponse implements Response {
|
|||
}
|
||||
|
||||
clone(): Response {
|
||||
throw Error("not implemented");
|
||||
notImplemented();
|
||||
}
|
||||
|
||||
onHeader: (res: Response) => void;
|
||||
|
|
4
js/os.ts
4
js/os.ts
|
@ -16,7 +16,7 @@ export function exit(exitCode = 0): never {
|
|||
fbs.Base.addMsgType(builder, fbs.Any.Exit);
|
||||
builder.finish(fbs.Base.endBase(builder));
|
||||
libdeno.send(builder.asUint8Array());
|
||||
throw Error("Unreachable");
|
||||
return util.unreachable();
|
||||
}
|
||||
|
||||
export function codeFetch(
|
||||
|
@ -131,7 +131,7 @@ export function writeFileSync(
|
|||
data: Uint8Array,
|
||||
perm: number
|
||||
): void {
|
||||
assert(false, "Not Implemented");
|
||||
util.notImplemented();
|
||||
/*
|
||||
pubInternal("os", {
|
||||
command: fbs.Command.WRITE_FILE_SYNC,
|
||||
|
|
|
@ -313,7 +313,7 @@ class TypeScriptHost implements ts.LanguageServiceHost {
|
|||
|
||||
readFile(path: string, encoding?: string): string | undefined {
|
||||
util.log("readFile", path);
|
||||
throw Error("not implemented");
|
||||
return util.notImplemented();
|
||||
}
|
||||
|
||||
getNewLine() {
|
||||
|
|
|
@ -67,3 +67,11 @@ export function createResolvable<T>(): Resolvable<T> {
|
|||
// therefore use of not null assertion (`!`)
|
||||
return Object.assign(promise, methods!) as Resolvable<T>;
|
||||
}
|
||||
|
||||
export function notImplemented(): never {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
export function unreachable(): never {
|
||||
throw new Error("Code not reachable");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue