@@ -125,7 +125,7 @@ added:
125125-->
126126
127127Creates a new instance of ` AsyncLocalStorage ` . Store is only provided within a
128- ` run() ` call or after an ` enterWith ()` call.
128+ ` run() ` call or after an ` set ()` call.
129129
130130### ` asyncLocalStorage.disable() `
131131
@@ -139,7 +139,7 @@ added:
139139
140140Disables the instance of ` AsyncLocalStorage ` . All subsequent calls
141141to ` asyncLocalStorage.getStore() ` will return ` undefined ` until
142- ` asyncLocalStorage.run() ` or ` asyncLocalStorage.enterWith () ` is called again.
142+ ` asyncLocalStorage.run() ` or ` asyncLocalStorage.set () ` is called again.
143143
144144When calling ` asyncLocalStorage.disable() ` , all current contexts linked to the
145145instance will be exited.
@@ -164,7 +164,7 @@ added:
164164
165165Returns the current store.
166166If called outside of an asynchronous context initialized by
167- calling ` asyncLocalStorage.run() ` or ` asyncLocalStorage.enterWith () ` , it
167+ calling ` asyncLocalStorage.run() ` or ` asyncLocalStorage.set () ` , it
168168returns ` undefined ` .
169169
170170### ` asyncLocalStorage.enterWith(store) `
@@ -173,13 +173,26 @@ returns `undefined`.
173173added:
174174 - v13.11.0
175175 - v12.17.0
176+ deprecated:
177+ - REPLACEME
178+ -->
179+
180+ > Stability: 0 - Deprecated: Use [ ` asyncLocalStorage.set(store) ` ] [ ]
181+
182+ This is a deprecated alias for [ ` asyncLocalStorage.set(store) ` ] [ ] .
183+
184+ ### ` asyncLocalStorage.set(store) `
185+
186+ <!-- YAML
187+ added:
188+ - REPLACEME
176189-->
177190
178191> Stability: 1 - Experimental
179192
180193* ` store ` {any}
181194
182- Transitions into the context for the remainder of the current
195+ Sets ` store ` on current execution context for the remainder of the current
183196synchronous execution and then persists the store through any following
184197asynchronous calls.
185198
@@ -188,7 +201,7 @@ Example:
188201``` js
189202const store = { id: 1 };
190203// Replaces previous store with the given store object
191- asyncLocalStorage .enterWith (store);
204+ asyncLocalStorage .set (store);
192205asyncLocalStorage .getStore (); // Returns the store object
193206someAsyncOperation (() => {
194207 asyncLocalStorage .getStore (); // Returns the same object
@@ -199,14 +212,14 @@ This transition will continue for the _entire_ synchronous execution.
199212This means that if, for example, the context is entered within an event
200213handler subsequent event handlers will also run within that context unless
201214specifically bound to another context with an ` AsyncResource ` . That is why
202- ` run() ` should be preferred over ` enterWith ()` unless there are strong reasons
215+ ` run() ` should be preferred over ` set ()` unless there are strong reasons
203216to use the latter method.
204217
205218``` js
206219const store = { id: 1 };
207220
208221emitter .on (' my-event' , () => {
209- asyncLocalStorage .enterWith (store);
222+ asyncLocalStorage .set (store);
210223});
211224emitter .on (' my-event' , () => {
212225 asyncLocalStorage .getStore (); // Returns the same object
@@ -816,4 +829,5 @@ const server = createServer((req, res) => {
816829[` EventEmitter` ]: events.md#class-eventemitter
817830[` Stream` ]: stream.md#stream
818831[` Worker ` ]: worker_threads.md#class-worker
832+ [` asyncLocalStorage .set (store)` ]: #asynclocalstoragesetstore`
819833[` util.promisify()` ]: util .md #utilpromisifyoriginal
0 commit comments