Fix dependabot issues

This commit is contained in:
Andrew Eisenberg 2021-10-21 15:24:20 -07:00
parent c89d9bd8b0
commit 531c6ba7c8
705 changed files with 53406 additions and 20466 deletions

119
node_modules/emittery/readme.md generated vendored
View file

@ -2,7 +2,8 @@
> Simple and modern async event emitter
[![Build Status](https://travis-ci.org/sindresorhus/emittery.svg?branch=master)](https://travis-ci.org/sindresorhus/emittery) [![codecov](https://codecov.io/gh/sindresorhus/emittery/branch/master/graph/badge.svg)](https://codecov.io/gh/sindresorhus/emittery) [![](https://badgen.net/bundlephobia/minzip/emittery)](https://bundlephobia.com/result?p=emittery)
[![Coverage Status](https://codecov.io/gh/sindresorhus/emittery/branch/master/graph/badge.svg)](https://codecov.io/gh/sindresorhus/emittery)
[![](https://badgen.net/bundlephobia/minzip/emittery)](https://bundlephobia.com/result?p=emittery)
It works in Node.js and the browser (using a bundler).
@ -45,14 +46,30 @@ Symbol event names can be used to avoid name collisions when your classes are ex
### emitter = new Emittery()
#### on(eventName, listener)
#### on(eventName | eventName[], listener)
Subscribe to an event.
Subscribe to one or more events.
Returns an unsubscribe method.
Using the same listener multiple times for the same event will result in only one method call per emitted event.
```js
const Emittery = require('emittery');
const emitter = new Emittery();
emitter.on('🦄', data => {
console.log(data);
});
emitter.on(['🦄', '🐶'], data => {
console.log(data);
});
emitter.emit('🦄', '🌈'); // log => '🌈' x2
emitter.emit('🐶', '🍖'); // log => '🍖'
```
##### Custom subscribable events
Emittery exports some symbols which represent custom events that can be passed to `Emitter.on` and similar methods.
@ -87,15 +104,34 @@ Only events that are not of this type are able to trigger these events.
##### listener(data)
#### off(eventName, listener)
#### off(eventName | eventName[], listener)
Remove an event subscription.
Remove one or more event subscriptions.
```js
const Emittery = require('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
})();
```
##### listener(data)
#### once(eventName)
#### once(eventName | eventName[])
Subscribe to an event only once. It will be unsubscribed after the first event.
Subscribe to one or more events only once. It will be unsubscribed after the first event.
Returns a promise for the event data when `eventName` is emitted.
@ -108,8 +144,12 @@ emitter.once('🦄').then(data => {
console.log(data);
//=> '🌈'
});
emitter.once(['🦄', '🐶']).then(data => {
console.log(data);
});
emitter.emit('🦄', '🌈');
emitter.emit('🦄', '🌈'); // Log => '🌈' x2
emitter.emit('🐶', '🍖'); // Nothing happens
```
#### events(eventName)
@ -164,6 +204,35 @@ for await (const data of iterator) {
}
```
It accepts multiple event names.
```js
const Emittery = require('emittery');
const emitter = new Emittery();
const iterator = emitter.events(['🦄', '🦊']);
emitter.emit('🦄', '🌈1'); // Buffered
emitter.emit('🦊', '🌈2'); // Buffered
iterator
.next()
.then(({value, done}) => {
// done === false
// value === '🌈1'
return iterator.next();
})
.then(({value, done}) => {
// done === false
// value === '🌈2'
// Revoke subscription
return iterator.return();
})
.then(({done}) => {
// done === true
});
```
#### emit(eventName, data?)
Trigger an event asynchronously, optionally with some data. Listeners are called in the order they were added, but executed concurrently.
@ -222,15 +291,15 @@ iterator.next()
In the same way as for `events`, you can subscribe by using the `for await` statement
#### clearListeners()
#### clearListeners(eventNames?)
Clear all event listeners on the instance.
If `eventName` is given, only the listeners for that event are cleared.
If `eventNames` is given, only the listeners for that events are cleared.
#### listenerCount(eventName?)
#### listenerCount(eventNames?)
The number of listeners for the `eventName` or all events if not specified.
The number of listeners for the `eventNames` or all events if not specified.
#### bindMethods(target, methodNames?)
@ -248,17 +317,31 @@ object.emit('event');
## TypeScript
The default `Emittery` class does not let you type allowed event names and their associated data. However, you can use `Emittery.Typed` with generics:
The default `Emittery` class has generic types that can be provided by TypeScript users to strongly type the list of events and the data passed to their event listeners.
```ts
import Emittery = require('emittery');
const emitter = new Emittery.Typed<{value: string}, 'open' | 'close'>();
const emitter = new Emittery<
// Pass `{[eventName]: undefined | <eventArg>}` as the first type argument for events that pass data to their listeners.
// A value of `undefined` in this map means the event listeners should expect no data, and a type other than `undefined` means the listeners will receive one argument of that type.
{
open: string,
close: undefined
}
>();
emitter.emit('open');
emitter.emit('value', 'foo\n');
emitter.emit('value', 1); // TS compilation error
emitter.emit('end'); // TS compilation error
// Typechecks just fine because the data type for the `open` event is `string`.
emitter.emit('open', 'foo\n');
// Typechecks just fine because `close` is present but points to undefined in the event data type map.
emitter.emit('close');
// TS compilation error because `1` isn't assignable to `string`.
emitter.emit('open', 1);
// TS compilation error because `other` isn't defined in the event data type map.
emitter.emit('other');
```
### Emittery.mixin(emitteryPropertyName, methodNames?)