mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
lib: add AsyncLocalStorage.bind() and .snapshot()
PR-URL: https://github.com/nodejs/node/pull/46387 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
This commit is contained in:
parent
225c578c77
commit
9a82938b82
4 changed files with 91 additions and 0 deletions
|
@ -287,6 +287,14 @@ class AsyncLocalStorage {
|
|||
this.enabled = false;
|
||||
}
|
||||
|
||||
static bind(fn) {
|
||||
return AsyncResource.bind(fn);
|
||||
}
|
||||
|
||||
static snapshot() {
|
||||
return AsyncLocalStorage.bind((cb, ...args) => cb(...args));
|
||||
}
|
||||
|
||||
disable() {
|
||||
if (this.enabled) {
|
||||
this.enabled = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue