source: trip-planner-front/node_modules/eventemitter-asyncresource/README.md@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1013 bytes
Line 
1# eventemitter-asyncresource - AsyncResource integration for EventEmitter
2
3Integrates [`EventEmitter`][] with [`AsyncResource`][] for `EventEmitter`s that
4require manual async tracking.
5
6```js
7const { EventEmitterAsyncResource } = require('eventemitter-asyncresource');
8
9// Async tracking tooling will identify this as 'Q'.
10const ee = new EventEmitterAsyncResource({ name: 'Q' });
11
12// 'foo' listeners will run in this EventEmitter’s async context.P
13ee.emit('foo');
14```
15
16The `EventEmitterAsyncResource` class has the same methods and takes the same
17options as `EventEmitter` and `AsyncResource` themselves.
18
19It provides an `.asyncResource` property that allows accessing the async
20resource in question, which in turn provides the original `EventEmitter` via
21`.eventEmitter`, i.e. in the above example
22`ee.asyncResource.eventEmitter === ee`.
23
24[`EventEmitter`]: https://nodejs.org/api/events.html#events_class_eventemitter
25[`AsyncResource`]: https://nodejs.org/api/async_hooks.html#async_hooks_class_asyncresource
Note: See TracBrowser for help on using the repository browser.