Socket
Socket
Sign inDemoInstall

p-event

Package Overview
Dependencies
2
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.1.0 to 4.2.0

35

index.d.ts
/// <reference lib="esnext"/>
declare class TimeoutErrorClass extends Error {
readonly name: 'TimeoutError';
constructor(message?: string);
}
declare namespace pEvent {
type TimeoutError = TimeoutErrorClass;
type AddRemoveListener<EventName extends string | symbol, Arguments extends unknown[]> = (
event: EventName,
listener: (...args: Arguments) => void
listener: (...arguments: Arguments) => void
) => void;

@@ -19,3 +26,3 @@

type FilterFunction<ElementType extends unknown[]> = (
...args: ElementType
...arguments: ElementType
) => boolean;

@@ -33,3 +40,3 @@

*/
readonly rejectionEvents?: (string | symbol)[];
readonly rejectionEvents?: ReadonlyArray<string | symbol>;

@@ -147,3 +154,3 @@ /**

*/
resolutionEvents?: (string | symbol)[];
resolutionEvents?: ReadonlyArray<string | symbol>;
}

@@ -192,3 +199,3 @@

emitter: pEvent.Emitter<EventName, EmittedType>,
event: string | symbol | (string | symbol)[],
event: string | symbol | ReadonlyArray<string | symbol>,
options: pEvent.MultiArgumentsOptions<EmittedType>

@@ -198,3 +205,3 @@ ): pEvent.CancelablePromise<EmittedType>;

emitter: pEvent.Emitter<EventName, [EmittedType]>,
event: string | symbol | (string | symbol)[],
event: string | symbol | ReadonlyArray<string | symbol>,
filter: pEvent.FilterFunction<[EmittedType]>

@@ -204,3 +211,3 @@ ): pEvent.CancelablePromise<EmittedType>;

emitter: pEvent.Emitter<EventName, [EmittedType]>,
event: string | symbol | (string | symbol)[],
event: string | symbol | ReadonlyArray<string | symbol>,
options?: pEvent.Options<[EmittedType]>

@@ -214,3 +221,3 @@ ): pEvent.CancelablePromise<EmittedType>;

emitter: pEvent.Emitter<EventName, EmittedType>,
event: string | symbol | (string | symbol)[],
event: string | symbol | ReadonlyArray<string | symbol>,
options: pEvent.MultipleMultiArgumentsOptions<EmittedType>

@@ -220,3 +227,3 @@ ): pEvent.CancelablePromise<EmittedType[]>;

emitter: pEvent.Emitter<EventName, [EmittedType]>,
event: string | symbol | (string | symbol)[],
event: string | symbol | ReadonlyArray<string | symbol>,
options: pEvent.MultipleOptions<[EmittedType]>

@@ -226,3 +233,3 @@ ): pEvent.CancelablePromise<EmittedType[]>;

/**
@returns An [async iterator](http://2ality.com/2016/10/asynchronous-iteration.html) that lets you asynchronously iterate over events of `event` emitted from `emitter`. The iterator ends when `emitter` emits an event matching any of the events defined in `resolutionEvents`, or rejects if `emitter` emits any of the events defined in the `rejectionEvents` option.
@returns An [async iterator](https://2ality.com/2016/10/asynchronous-iteration.html) that lets you asynchronously iterate over events of `event` emitted from `emitter`. The iterator ends when `emitter` emits an event matching any of the events defined in `resolutionEvents`, or rejects if `emitter` emits any of the events defined in the `rejectionEvents` option.

@@ -247,3 +254,3 @@ @example

emitter: pEvent.Emitter<EventName, EmittedType>,
event: string | symbol | (string | symbol)[],
event: string | symbol | ReadonlyArray<string | symbol>,
options: pEvent.IteratorMultiArgumentsOptions<EmittedType>

@@ -253,3 +260,3 @@ ): AsyncIterableIterator<EmittedType>;

emitter: pEvent.Emitter<EventName, [EmittedType]>,
event: string | symbol | (string | symbol)[],
event: string | symbol | ReadonlyArray<string | symbol>,
filter: pEvent.FilterFunction<[EmittedType]>

@@ -259,3 +266,3 @@ ): AsyncIterableIterator<EmittedType>;

emitter: pEvent.Emitter<EventName, [EmittedType]>,
event: string | symbol | (string | symbol)[],
event: string | symbol | ReadonlyArray<string | symbol>,
options?: pEvent.IteratorOptions<[EmittedType]>

@@ -266,4 +273,6 @@ ): AsyncIterableIterator<EmittedType>;

default: typeof pEvent;
TimeoutError: typeof TimeoutErrorClass;
};
export = pEvent;

@@ -20,3 +20,3 @@ 'use strict';

const normalizeEvents = event => Array.isArray(event) ? event : [event];
const toArray = value => Array.isArray(value) ? value : [value];

@@ -38,3 +38,3 @@ const multiple = (emitter, event, options) => {

// Allow multiple events
const events = normalizeEvents(event);
const events = toArray(event);

@@ -128,3 +128,3 @@ const items = [];

// Allow multiple events
const events = normalizeEvents(event);
const events = toArray(event);

@@ -293,1 +293,3 @@ options = {

};
module.exports.TimeoutError = pTimeout.TimeoutError;
{
"name": "p-event",
"version": "4.1.0",
"version": "4.2.0",
"description": "Promisify an event by waiting for it to be emitted",
"license": "MIT",
"repository": "sindresorhus/p-event",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},

@@ -46,11 +47,11 @@ "engines": {

"dependencies": {
"p-timeout": "^2.0.1"
"p-timeout": "^3.1.0"
},
"devDependencies": {
"@types/node": "^11.13.0",
"@types/node": "^12.0.2",
"ava": "^1.4.1",
"delay": "^4.1.0",
"tsd": "^0.7.2",
"tsd": "^0.11.0",
"xo": "^0.24.0"
}
}

@@ -1,2 +0,2 @@

# p-event [![Build Status](https://travis-ci.org/sindresorhus/p-event.svg?branch=master)](https://travis-ci.org/sindresorhus/p-event)
# p-event [![Build Status](https://travis-ci.com/sindresorhus/p-event.svg?branch=master)](https://travis-ci.com/sindresorhus/p-event)

@@ -11,3 +11,2 @@ > Promisify an event by waiting for it to be emitted

## Install

@@ -19,3 +18,2 @@

## Usage

@@ -70,6 +68,5 @@

## API
### pEvent(emitter, event, [options])
### pEvent(emitter, event, options?)
### pEvent(emitter, event, filter)

@@ -86,3 +83,3 @@

Type: `Object`
Type: `object`

@@ -103,7 +100,7 @@ Event emitter object.

Type: `Object`
Type: `object`
##### rejectionEvents
Type: `string[]`<br>
Type: `string[]`\
Default: `['error']`

@@ -115,3 +112,3 @@

Type: `boolean`<br>
Type: `boolean`\
Default: `false`

@@ -134,3 +131,3 @@

Type: `number`<br>
Type: `number`\
Default: `Infinity`

@@ -164,7 +161,7 @@

Type: `Object`
Type: `object`
##### count
*Required*<br>
*Required*\
Type: `number`

@@ -176,3 +173,3 @@

Type: `boolean`<br>
Type: `boolean`\
Default: `false`

@@ -216,6 +213,6 @@

### pEvent.iterator(emitter, event, [options])
### pEvent.iterator(emitter, event, options?)
### pEvent.iterator(emitter, event, filter)
Returns an [async iterator](http://2ality.com/2016/10/asynchronous-iteration.html) that lets you asynchronously iterate over events of `event` emitted from `emitter`. The iterator ends when `emitter` emits an event matching any of the events defined in `resolutionEvents`, or rejects if `emitter` emits any of the events defined in the `rejectionEvents` option.
Returns an [async iterator](https://2ality.com/2016/10/asynchronous-iteration.html) that lets you asynchronously iterate over events of `event` emitted from `emitter`. The iterator ends when `emitter` emits an event matching any of the events defined in `resolutionEvents`, or rejects if `emitter` emits any of the events defined in the `rejectionEvents` option.

@@ -226,7 +223,7 @@ This method has the same arguments and options as `pEvent()` with the addition of the following options:

Type: `Object`
Type: `object`
##### limit
Type: `number` *(non-negative integer)*<br>
Type: `number` *(non-negative integer)*\
Default: `Infinity`

@@ -238,3 +235,3 @@

Type: `string[]`<br>
Type: `string[]`\
Default: `[]`

@@ -244,3 +241,20 @@

### pEvent.TimeoutError
Exposed for instance checking and sub-classing.
Example:
```js
const pEvent = require('p-event');
try {
await pEvent(emitter, 'finish');
} catch (error) {
if (error instanceof pEvent.TimeoutError) {
// Do something specific for timeout errors
}
}
```
## Before and after

@@ -291,3 +305,2 @@

## Tip

@@ -321,3 +334,2 @@

## Related

@@ -328,6 +340,1 @@

- [More…](https://github.com/sindresorhus/promise-fun)
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc