summaryrefslogtreecommitdiff
path: root/core/lib.deno_core.d.ts
diff options
context:
space:
mode:
authorGuilherme Bernal <guilherme@cubos.io>2022-09-28 11:09:33 -0300
committerGitHub <noreply@github.com>2022-09-28 16:09:33 +0200
commit6c55772f0d5101e0d2b8df3b0653a02e1581122f (patch)
treec63e36c5a7822f0ad7d620f078604b81f5792b82 /core/lib.deno_core.d.ts
parentb8e3f4c71dae5b43a03e8cfb36e71865e8eeaabf (diff)
feat(core): add Deno.core.setPromiseHooks (#15475)
Diffstat (limited to 'core/lib.deno_core.d.ts')
-rw-r--r--core/lib.deno_core.d.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/lib.deno_core.d.ts b/core/lib.deno_core.d.ts
index c5662794a..7e46d0f14 100644
--- a/core/lib.deno_core.d.ts
+++ b/core/lib.deno_core.d.ts
@@ -164,5 +164,26 @@ declare namespace Deno {
* enabled.
*/
const opCallTraces: Map<number, OpCallTrace>;
+
+ /**
+ * Adds a callback for the given Promise event. If this function is called
+ * multiple times, the callbacks are called in the order they were added.
+ * - `init_hook` is called when a new promise is created. When a new promise
+ * is created as part of the chain in the case of `Promise.then` or in the
+ * intermediate promises created by `Promise.{race, all}`/`AsyncFunctionAwait`,
+ * we pass the parent promise otherwise we pass undefined.
+ * - `before_hook` is called at the beginning of the promise reaction.
+ * - `after_hook` is called at the end of the promise reaction.
+ * - `resolve_hook` is called at the beginning of resolve or reject function.
+ */
+ function setPromiseHooks(
+ init_hook?: (
+ promise: Promise<unknown>,
+ parentPromise?: Promise<unknown>,
+ ) => void,
+ before_hook?: (promise: Promise<unknown>) => void,
+ after_hook?: (promise: Promise<unknown>) => void,
+ resolve_hook?: (promise: Promise<unknown>) => void,
+ ): void;
}
}