Skip to content

Commit

Permalink
doc: add missing imports in events sample code
Browse files Browse the repository at this point in the history
There were missing imports in the example for using
`EventEmitterAsyncResource`, so I added them in both ESM and CJS.

PR-URL: #44337
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
  • Loading branch information
mrbrianevans authored and targos committed Sep 16, 2022
1 parent 2942d9f commit 800a348
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions doc/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -1478,9 +1478,9 @@ require manual async tracking. Specifically, all events emitted by instances
of `events.EventEmitterAsyncResource` will run within its [async context][].

```mjs
import { EventEmitterAsyncResource } from 'node:events';
import { EventEmitterAsyncResource, EventEmitter } from 'node:events';
import { notStrictEqual, strictEqual } from 'node:assert';
import { executionAsyncId } from 'node:async_hooks';
import { executionAsyncId, triggerAsyncId } from 'node:async_hooks';

// Async tracking tooling will identify this as 'Q'.
const ee1 = new EventEmitterAsyncResource({ name: 'Q' });
Expand All @@ -1507,9 +1507,9 @@ Promise.resolve().then(() => {
```

```cjs
const { EventEmitterAsyncResource } = require('node:events');
const { EventEmitterAsyncResource, EventEmitter } = require('node:events');
const { notStrictEqual, strictEqual } = require('node:assert');
const { executionAsyncId } = require('node:async_hooks');
const { executionAsyncId, triggerAsyncId } = require('node:async_hooks');

// Async tracking tooling will identify this as 'Q'.
const ee1 = new EventEmitterAsyncResource({ name: 'Q' });
Expand Down

0 comments on commit 800a348

Please sign in to comment.