From 3aacf44950bcf5b5c73d8f16b964522067c566cb Mon Sep 17 00:00:00 2001 From: flakey5 <73616808+flakey5@users.noreply.github.com> Date: Fri, 27 Jan 2023 19:12:19 -0800 Subject: [PATCH] Apply suggestions from code review Co-authored-by: James M Snell --- doc/api/async_context.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/api/async_context.md b/doc/api/async_context.md index 9b1fb9bcd81b10..a5d9027b9cc4be 100644 --- a/doc/api/async_context.md +++ b/doc/api/async_context.md @@ -147,7 +147,7 @@ this time will print the stack trace and exit. See Creating an async resource within the `onPropagate` callback will result in a recursive call to `onPropagate`. -### `asyncLocalStorage.bind(fn, thisArg)` +### `asyncLocalStorage.bind(fn [, thisArg])` -Returns a callback that captures the current async context and invokes a callback passed into it within the captured async context. +Returns a callback that captures the current async context and invokes a callback passed into it +within the captured async context. ```js const asyncLocalStorage = new AsyncLocalStorage(); const runInAsyncScope = asyncLocalStorage.run(123, () => als.snapshot()); const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore())); -console.log(result) // returns 123 +console.log(result); // returns 123 ``` AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple async context tracking purposes, for example: