1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 17:49:08 -05:00
denoland-deno/js/libdeno.ts
Ryan Dahl 1b7938e3aa
Add libdeno.builtinModules (#1463)
This is needed to support builtin modules like

    import { open } from "deno"
2019-01-06 16:32:21 -05:00

46 lines
1.1 KiB
TypeScript

// Copyright 2018 the Deno authors. All rights reserved. MIT license.
import { globalEval } from "./global_eval";
// The libdeno functions are moved so that users can't access them.
type MessageCallback = (msg: Uint8Array) => void;
export type PromiseRejectEvent =
| "RejectWithNoHandler"
| "HandlerAddedAfterReject"
| "ResolveAfterResolved"
| "RejectAfterResolved";
interface Libdeno {
recv(cb: MessageCallback): void;
send(control: ArrayBufferView, data?: ArrayBufferView): null | Uint8Array;
print(x: string, isErr?: boolean): void;
shared: ArrayBuffer;
builtinModules: { [s: string]: object };
setGlobalErrorHandler: (
handler: (
message: string,
source: string,
line: number,
col: number,
error: Error
) => void
) => void;
setPromiseRejectHandler: (
handler: (
error: Error | string,
event: PromiseRejectEvent,
/* tslint:disable-next-line:no-any */
promise: Promise<any>
) => void
) => void;
setPromiseErrorExaminer: (handler: () => boolean) => void;
}
const window = globalEval("this");
export const libdeno = window.libdeno as Libdeno;