X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=%40types%2Fevents.d.ts;h=b5338939859c39642f667a2854d3da5ddf9b98df;hb=2d222913a09a96b2a78b0c2072ddff98973a35a5;hp=e5504f0ad6e22d0c6ad56cac012fa60c6fbd1274;hpb=b560403426309944ad775794161773a745263190;p=poolifier.git diff --git a/@types/events.d.ts b/@types/events.d.ts index e5504f0a..b5338939 100644 --- a/@types/events.d.ts +++ b/@types/events.d.ts @@ -1,7 +1,7 @@ import type { AsyncResource, AsyncResourceOptions } from 'node:async_hooks' import { EventEmitter } from 'node:events' -declare module 'node:events' { +declare module 'events' { interface EventEmitterOptions { /** * Enables automatic capturing of promise rejection. @@ -14,35 +14,39 @@ declare module 'node:events' { EventEmitterOptions { /** * The type of async event. - * @default new.target.name + * @default new.target.name if instantiated as a child class. */ name?: string } /** - * Integrates `EventEmitter` with `AsyncResource` for `EventEmitters` that require + * Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that require * manual async tracking. Specifically, all events emitted by instances of * `EventEmitterAsyncResource` will run within its async context. * * The EventEmitterAsyncResource class has the same methods and takes the * same options as EventEmitter and AsyncResource themselves. + * @throws if `options.name` is not provided when instantiated directly. + * @since v17.4.0, v16.14.0 */ export class EventEmitterAsyncResource extends EventEmitter { + /** + * @param options Only optional in child class. + */ constructor (options?: EventEmitterAsyncResourceOptions) /** * Call all `destroy` hooks. This should only ever be called once. An error will * be thrown if it is called more than once. This **must** be manually called. If * the resource is left to be collected by the GC then the `destroy` hooks will * never be called. - * @return A reference to `asyncResource`. */ - emitDestroy (): AsyncResource + emitDestroy (): void /** The unique asyncId assigned to the resource. */ - get asyncId (): number + readonly asyncId: number /** The same triggerAsyncId that is passed to the AsyncResource constructor. */ - get triggerAsyncId (): number + readonly triggerAsyncId: number /** The underlying AsyncResource */ - get asyncResource (): AsyncResource & { + readonly asyncResource: AsyncResource & { readonly eventEmitter: EventEmitterAsyncResource } }