1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 09:39:08 -05:00
denoland-deno/js/libdeno.ts

50 lines
1.2 KiB
TypeScript
Raw Normal View History

2018-10-19 15:25:29 -04:00
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
import { RawSourceMap } from "./types";
2018-10-03 21:41:59 -04:00
import { globalEval } from "./global_eval";
// The libdeno functions are moved so that users can't access them.
type MessageCallback = (msg: Uint8Array) => void;
2018-10-12 14:22:52 -04:00
export type PromiseRejectEvent =
| "RejectWithNoHandler"
| "HandlerAddedAfterReject"
| "ResolveAfterResolved"
| "RejectAfterResolved";
interface Libdeno {
recv(cb: MessageCallback): void;
send(control: ArrayBufferView, data?: ArrayBufferView): null | Uint8Array;
2018-09-25 01:27:02 -04:00
print(x: string, isErr?: boolean): void;
shared: ArrayBuffer;
setGlobalErrorHandler: (
handler: (
message: string,
source: string,
line: number,
col: number,
error: Error
) => void
) => void;
2018-10-12 14:22:52 -04:00
setPromiseRejectHandler: (
handler: (
error: Error | string,
event: PromiseRejectEvent,
/* tslint:disable-next-line:no-any */
promise: Promise<any>
) => void
) => void;
setPromiseErrorExaminer: (handler: () => boolean) => void;
mainSource: string;
mainSourceMap: RawSourceMap;
}
const window = globalEval("this");
2018-11-08 23:07:48 -05:00
// @internal
export const libdeno = window.libdeno as Libdeno;