Skip to content

Commit

Permalink
Minor docs improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Qard committed Dec 19, 2019
1 parent 793282f commit d08abdb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions doc/api/async_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,15 +466,14 @@ init for PROMISE with id 6, trigger id: 5 # the Promise returned by then()
added: REPLACEME
-->

* Returns: {Object} The resource that triggered the current
execution context.
* Returns: {Object} The resource representing the current execution.
Useful to store data within the resource.

```js
const { open } = require('fs');
const { executionAsyncId, executionAsyncResource } = require('async_hooks');

console.log(executionAsyncId(), executionAsyncResource()); // 1 null
console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
open(__filename, 'r', (err, fd) => {
console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
});
Expand Down Expand Up @@ -513,6 +512,10 @@ Resource objects returned by `executionAsyncResource()` are often internal
handle objects with undocumented APIs. Using any functions or properties
on the object is not recommended and may crash your application.

Using `executionAsyncResource()` in the top-level execution context will
return an empty object as there is no handle or request object to use,
but having an object representing the top-level can be helpful.

#### async_hooks.executionAsyncId()

<!-- YAML
Expand Down

0 comments on commit d08abdb

Please sign in to comment.