summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/async_hooks.ts
diff options
context:
space:
mode:
authorAlex Yang <himself65@outlook.com>2024-04-02 17:53:29 -0500
committerGitHub <noreply@github.com>2024-04-02 22:53:29 +0000
commit8eb2b6c61f9fdac12f8bab23ad3e9ef71c7c59b1 (patch)
tree2f214f52b873d4dabd2a7e24e082206ae3c29656 /ext/node/polyfills/async_hooks.ts
parentc0b7454175afdefa0b8e73a04aadeb874eb2e766 (diff)
feat: improve AsyncLocalStorage api (#23175)
Fixes: https://github.com/denoland/deno/issues/23174
Diffstat (limited to 'ext/node/polyfills/async_hooks.ts')
-rw-r--r--ext/node/polyfills/async_hooks.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/node/polyfills/async_hooks.ts b/ext/node/polyfills/async_hooks.ts
index d60334346..ea0bfb944 100644
--- a/ext/node/polyfills/async_hooks.ts
+++ b/ext/node/polyfills/async_hooks.ts
@@ -316,6 +316,17 @@ export class AsyncLocalStorage {
);
Scope.enter(frame);
}
+
+ static bind(fn: (...args: unknown[]) => unknown) {
+ return AsyncResource.bind(fn);
+ }
+
+ static snapshot() {
+ return AsyncLocalStorage.bind((
+ cb: (...args: unknown[]) => unknown,
+ ...args: unknown[]
+ ) => cb(...args));
+ }
}
export function executionAsyncId() {