mirror of
https://github.com/denoland/deno.git
synced 2024-10-30 09:08:00 -04:00
c113df1bb8
- Improves speed and binary size significantly. - Makes deno_last_exception() output a JSON structure. - Isolate::execute and Isolate::event_loop now return structured, mapped JSError objects on errors. - Removes libdeno functions: libdeno.setGlobalErrorHandler() libdeno.setPromiseRejectHandler() libdeno.setPromiseErrorExaminer() In collaboration with Ryan Dahl.
45 lines
1.1 KiB
TypeScript
45 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;
|
|
|
|
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");
|
|
// @internal
|
|
export const libdeno = window.libdeno as Libdeno;
|