Bump packages to fix linter
This commit is contained in:
parent
ed9506bbaf
commit
0a11e3fdd9
6063 changed files with 378752 additions and 306784 deletions
188
node_modules/emittery/index.d.ts
generated
vendored
188
node_modules/emittery/index.d.ts
generated
vendored
|
|
@ -1,11 +1,9 @@
|
|||
/* eslint-disable no-redeclare */
|
||||
|
||||
/**
|
||||
Emittery accepts strings, symbols, and numbers as event names.
|
||||
|
||||
Symbol event names are preferred given that they can be used to avoid name collisions when your classes are extended, especially for internal events.
|
||||
*/
|
||||
type EventName = PropertyKey;
|
||||
export type EventName = PropertyKey;
|
||||
|
||||
// Helper type for turning the passed `EventData` type map into a list of string keys that don't require data alongside the event name when emitting. Uses the same trick that `Omit` does internally to filter keys by building a map of keys to keys we want to keep, and then accessing all the keys to return just the list of keys we want to keep.
|
||||
type DatalessEventNames<EventData> = {
|
||||
|
|
@ -14,7 +12,7 @@ type DatalessEventNames<EventData> = {
|
|||
|
||||
declare const listenerAdded: unique symbol;
|
||||
declare const listenerRemoved: unique symbol;
|
||||
type _OmnipresentEventData = {[listenerAdded]: Emittery.ListenerChangedData; [listenerRemoved]: Emittery.ListenerChangedData};
|
||||
type OmnipresentEventData = {[listenerAdded]: ListenerChangedData; [listenerRemoved]: ListenerChangedData};
|
||||
|
||||
/**
|
||||
Emittery can collect and log debug information.
|
||||
|
|
@ -23,12 +21,12 @@ To enable this feature set the `DEBUG` environment variable to `emittery` or `*`
|
|||
|
||||
See API for more information on how debugging works.
|
||||
*/
|
||||
type DebugLogger<EventData, Name extends keyof EventData> = (type: string, debugName: string, eventName?: Name, eventData?: EventData[Name]) => void;
|
||||
export type DebugLogger<EventData, Name extends keyof EventData> = (type: string, debugName: string, eventName?: Name, eventData?: EventData[Name]) => void;
|
||||
|
||||
/**
|
||||
Configure debug options of an instance.
|
||||
*/
|
||||
interface DebugOptions<EventData> {
|
||||
export type DebugOptions<EventData> = {
|
||||
/**
|
||||
Define a name for the instance of Emittery to use when outputting debug data.
|
||||
|
||||
|
|
@ -36,7 +34,7 @@ interface DebugOptions<EventData> {
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
Emittery.isDebugEnabled = true;
|
||||
|
||||
|
|
@ -60,7 +58,7 @@ interface DebugOptions<EventData> {
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const emitter1 = new Emittery({debug: {name: 'emitter1', enabled: true}});
|
||||
const emitter2 = new Emittery({debug: {name: 'emitter2'}});
|
||||
|
|
@ -80,7 +78,7 @@ interface DebugOptions<EventData> {
|
|||
emitter2.emit('test');
|
||||
```
|
||||
*/
|
||||
enabled?: boolean;
|
||||
readonly enabled?: boolean;
|
||||
|
||||
/**
|
||||
Function that handles debug data.
|
||||
|
|
@ -102,9 +100,11 @@ interface DebugOptions<EventData> {
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const myLogger = (type, debugName, eventName, eventData) => console.log(`[${type}]: ${eventName}`);
|
||||
const myLogger = (type, debugName, eventName, eventData) => {
|
||||
console.log(`[${type}]: ${eventName}`);
|
||||
};
|
||||
|
||||
const emitter = new Emittery({
|
||||
debug: {
|
||||
|
|
@ -122,15 +122,42 @@ interface DebugOptions<EventData> {
|
|||
//=> [subscribe]: test
|
||||
```
|
||||
*/
|
||||
logger?: DebugLogger<EventData, keyof EventData>;
|
||||
}
|
||||
readonly logger?: DebugLogger<EventData, keyof EventData>;
|
||||
};
|
||||
|
||||
/**
|
||||
Configuration options for Emittery.
|
||||
*/
|
||||
interface Options<EventData> {
|
||||
debug?: DebugOptions<EventData>;
|
||||
}
|
||||
export type Options<EventData> = {
|
||||
readonly debug?: DebugOptions<EventData>;
|
||||
};
|
||||
|
||||
/**
|
||||
A promise returned from `emittery.once` with an extra `off` method to cancel your subscription.
|
||||
*/
|
||||
export type EmitteryOncePromise<T> = {
|
||||
off(): void;
|
||||
} & Promise<T>;
|
||||
|
||||
/**
|
||||
Removes an event subscription.
|
||||
*/
|
||||
export type UnsubscribeFunction = () => void;
|
||||
|
||||
/**
|
||||
The data provided as `eventData` when listening for `Emittery.listenerAdded` or `Emittery.listenerRemoved`.
|
||||
*/
|
||||
export type ListenerChangedData = {
|
||||
/**
|
||||
The listener that was added or removed.
|
||||
*/
|
||||
listener: (eventData?: unknown) => (void | Promise<void>);
|
||||
|
||||
/**
|
||||
The name of the event that was added or removed if `.on()` or `.off()` was used, or `undefined` if `.onAny()` or `.offAny()` was used.
|
||||
*/
|
||||
eventName?: EventName;
|
||||
};
|
||||
|
||||
/**
|
||||
Emittery is a strictly typed, fully async EventEmitter implementation. Event listeners can be registered with `on` or `once`, and events can be emitted with `emit`.
|
||||
|
|
@ -139,7 +166,7 @@ Emittery is a strictly typed, fully async EventEmitter implementation. Event lis
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const emitter = new Emittery<
|
||||
// Pass `{[eventName: <string | symbol | number>]: undefined | <eventArg>}` as the first type argument for events that pass data to their listeners.
|
||||
|
|
@ -163,10 +190,10 @@ emitter.emit('open', 1);
|
|||
emitter.emit('other');
|
||||
```
|
||||
*/
|
||||
declare class Emittery<
|
||||
EventData = Record<EventName, any>,
|
||||
AllEventData = EventData & _OmnipresentEventData,
|
||||
DatalessEvents = DatalessEventNames<EventData>
|
||||
export default class Emittery<
|
||||
EventData = Record<EventName, any>, // TODO: Use `unknown` instead of `any`.
|
||||
AllEventData = EventData & OmnipresentEventData,
|
||||
DatalessEvents = DatalessEventNames<EventData>,
|
||||
> {
|
||||
/**
|
||||
Toggle debug mode for all instances.
|
||||
|
|
@ -175,7 +202,7 @@ declare class Emittery<
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
Emittery.isDebugEnabled = true;
|
||||
|
||||
|
|
@ -208,7 +235,7 @@ declare class Emittery<
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const emitter = new Emittery();
|
||||
|
||||
|
|
@ -234,7 +261,7 @@ declare class Emittery<
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const emitter = new Emittery();
|
||||
|
||||
|
|
@ -255,24 +282,12 @@ declare class Emittery<
|
|||
*/
|
||||
static readonly listenerRemoved: typeof listenerRemoved;
|
||||
|
||||
/**
|
||||
Debugging options for the current instance.
|
||||
*/
|
||||
debug: DebugOptions<EventData>;
|
||||
|
||||
/**
|
||||
Create a new Emittery instance with the specified options.
|
||||
|
||||
@returns An instance of Emittery that you can use to listen for and emit events.
|
||||
*/
|
||||
constructor(options?: Options<EventData>);
|
||||
|
||||
/**
|
||||
In TypeScript, it returns a decorator which mixins `Emittery` as property `emitteryPropertyName` and `methodNames`, or all `Emittery` methods if `methodNames` is not defined, into the target class.
|
||||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
@Emittery.mixin('emittery')
|
||||
class MyClass {}
|
||||
|
|
@ -285,7 +300,19 @@ declare class Emittery<
|
|||
static mixin(
|
||||
emitteryPropertyName: string | symbol,
|
||||
methodNames?: readonly string[]
|
||||
): <T extends {new (): any}>(klass: T) => T; // eslint-disable-line @typescript-eslint/prefer-function-type
|
||||
): <T extends {new (...arguments_: readonly any[]): any}>(klass: T) => T; // eslint-disable-line @typescript-eslint/prefer-function-type
|
||||
|
||||
/**
|
||||
Debugging options for the current instance.
|
||||
*/
|
||||
debug: DebugOptions<EventData>;
|
||||
|
||||
/**
|
||||
Create a new Emittery instance with the specified options.
|
||||
|
||||
@returns An instance of Emittery that you can use to listen for and emit events.
|
||||
*/
|
||||
constructor(options?: Options<EventData>);
|
||||
|
||||
/**
|
||||
Subscribe to one or more events.
|
||||
|
|
@ -296,7 +323,7 @@ declare class Emittery<
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const emitter = new Emittery();
|
||||
|
||||
|
|
@ -313,9 +340,9 @@ declare class Emittery<
|
|||
```
|
||||
*/
|
||||
on<Name extends keyof AllEventData>(
|
||||
eventName: Name | Name[],
|
||||
eventName: Name | readonly Name[],
|
||||
listener: (eventData: AllEventData[Name]) => void | Promise<void>
|
||||
): Emittery.UnsubscribeFn;
|
||||
): UnsubscribeFunction;
|
||||
|
||||
/**
|
||||
Get an async iterator which buffers data each time an event is emitted.
|
||||
|
|
@ -324,7 +351,7 @@ declare class Emittery<
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const emitter = new Emittery();
|
||||
const iterator = emitter.events('🦄');
|
||||
|
|
@ -354,7 +381,7 @@ declare class Emittery<
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const emitter = new Emittery();
|
||||
const iterator = emitter.events('🦄');
|
||||
|
|
@ -374,7 +401,7 @@ declare class Emittery<
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const emitter = new Emittery();
|
||||
const iterator = emitter.events(['🦄', '🦊']);
|
||||
|
|
@ -401,7 +428,7 @@ declare class Emittery<
|
|||
```
|
||||
*/
|
||||
events<Name extends keyof EventData>(
|
||||
eventName: Name | Name[]
|
||||
eventName: Name | readonly Name[]
|
||||
): AsyncIterableIterator<EventData[Name]>;
|
||||
|
||||
/**
|
||||
|
|
@ -409,26 +436,27 @@ declare class Emittery<
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const emitter = new Emittery();
|
||||
|
||||
const listener = data => console.log(data);
|
||||
(async () => {
|
||||
emitter.on(['🦄', '🐶', '🦊'], listener);
|
||||
await emitter.emit('🦄', 'a');
|
||||
await emitter.emit('🐶', 'b');
|
||||
await emitter.emit('🦊', 'c');
|
||||
emitter.off('🦄', listener);
|
||||
emitter.off(['🐶', '🦊'], listener);
|
||||
await emitter.emit('🦄', 'a'); // nothing happens
|
||||
await emitter.emit('🐶', 'b'); // nothing happens
|
||||
await emitter.emit('🦊', 'c'); // nothing happens
|
||||
})();
|
||||
const listener = data => {
|
||||
console.log(data);
|
||||
};
|
||||
|
||||
emitter.on(['🦄', '🐶', '🦊'], listener);
|
||||
await emitter.emit('🦄', 'a');
|
||||
await emitter.emit('🐶', 'b');
|
||||
await emitter.emit('🦊', 'c');
|
||||
emitter.off('🦄', listener);
|
||||
emitter.off(['🐶', '🦊'], listener);
|
||||
await emitter.emit('🦄', 'a'); // nothing happens
|
||||
await emitter.emit('🐶', 'b'); // nothing happens
|
||||
await emitter.emit('🦊', 'c'); // nothing happens
|
||||
```
|
||||
*/
|
||||
off<Name extends keyof AllEventData>(
|
||||
eventName: Name | Name[],
|
||||
eventName: Name | readonly Name[],
|
||||
listener: (eventData: AllEventData[Name]) => void | Promise<void>
|
||||
): void;
|
||||
|
||||
|
|
@ -436,11 +464,11 @@ declare class Emittery<
|
|||
Subscribe to one or more events only once. It will be unsubscribed after the first
|
||||
event.
|
||||
|
||||
@returns The event data when `eventName` is emitted.
|
||||
@returns The promise of event data when `eventName` is emitted. This promise is extended with an `off` method.
|
||||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const emitter = new Emittery();
|
||||
|
||||
|
|
@ -457,7 +485,7 @@ declare class Emittery<
|
|||
emitter.emit('🐶', '🍖'); // Nothing happens
|
||||
```
|
||||
*/
|
||||
once<Name extends keyof AllEventData>(eventName: Name | Name[]): Promise<AllEventData[Name]>;
|
||||
once<Name extends keyof AllEventData>(eventName: Name | readonly Name[]): EmitteryOncePromise<AllEventData[Name]>;
|
||||
|
||||
/**
|
||||
Trigger an event asynchronously, optionally with some data. Listeners are called in the order they were added, but executed concurrently.
|
||||
|
|
@ -493,7 +521,7 @@ declare class Emittery<
|
|||
eventName: keyof EventData,
|
||||
eventData: EventData[keyof EventData]
|
||||
) => void | Promise<void>
|
||||
): Emittery.UnsubscribeFn;
|
||||
): UnsubscribeFunction;
|
||||
|
||||
/**
|
||||
Get an async iterator which buffers a tuple of an event name and data each time an event is emitted.
|
||||
|
|
@ -504,7 +532,7 @@ declare class Emittery<
|
|||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const emitter = new Emittery();
|
||||
const iterator = emitter.anyEvent();
|
||||
|
|
@ -548,19 +576,19 @@ declare class Emittery<
|
|||
|
||||
If `eventName` is given, only the listeners for that event are cleared.
|
||||
*/
|
||||
clearListeners<Name extends keyof EventData>(eventName?: Name | Name[]): void;
|
||||
clearListeners<Name extends keyof EventData>(eventName?: Name | readonly Name[]): void;
|
||||
|
||||
/**
|
||||
The number of listeners for the `eventName` or all events if not specified.
|
||||
*/
|
||||
listenerCount<Name extends keyof EventData>(eventName?: Name | Name[]): number;
|
||||
listenerCount<Name extends keyof EventData>(eventName?: Name | readonly Name[]): number;
|
||||
|
||||
/**
|
||||
Bind the given `methodNames`, or all `Emittery` methods if `methodNames` is not defined, into the `target` object.
|
||||
|
||||
@example
|
||||
```
|
||||
import Emittery = require('emittery');
|
||||
import Emittery from 'emittery';
|
||||
|
||||
const object = {};
|
||||
|
||||
|
|
@ -571,29 +599,3 @@ declare class Emittery<
|
|||
*/
|
||||
bindMethods(target: Record<string, unknown>, methodNames?: readonly string[]): void;
|
||||
}
|
||||
|
||||
declare namespace Emittery {
|
||||
/**
|
||||
Removes an event subscription.
|
||||
*/
|
||||
type UnsubscribeFn = () => void;
|
||||
|
||||
/**
|
||||
The data provided as `eventData` when listening for `Emittery.listenerAdded` or `Emittery.listenerRemoved`.
|
||||
*/
|
||||
interface ListenerChangedData {
|
||||
/**
|
||||
The listener that was added or removed.
|
||||
*/
|
||||
listener: (eventData?: unknown) => void | Promise<void>;
|
||||
|
||||
/**
|
||||
The name of the event that was added or removed if `.on()` or `.off()` was used, or `undefined` if `.onAny()` or `.offAny()` was used.
|
||||
*/
|
||||
eventName?: EventName;
|
||||
}
|
||||
|
||||
type OmnipresentEventData = _OmnipresentEventData;
|
||||
}
|
||||
|
||||
export = Emittery;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue