Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

p-event

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-event - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

77

index.d.ts
/// <reference lib="esnext"/>
export type AddRemoveListener<FirstArgumentType, RestArgumentsType> = (
export type AddRemoveListener<Arguments extends unknown[]> = (
event: string | symbol,
listener: (
firstArgument: FirstArgumentType,
...rest: RestArgumentsType[]
...args: Arguments,
) => void
) => void;
export interface Emitter<EmittedType, EmittedTypeRest> {
on?: AddRemoveListener<EmittedType, EmittedTypeRest>;
addListener?: AddRemoveListener<EmittedType, EmittedTypeRest>;
addEventListener?: AddRemoveListener<EmittedType, EmittedTypeRest>;
off?: AddRemoveListener<EmittedType, EmittedTypeRest>;
removeListener?: AddRemoveListener<EmittedType, EmittedTypeRest>;
removeEventListener?: AddRemoveListener<EmittedType, EmittedTypeRest>;
export interface Emitter<EmittedType extends unknown[]> {
on?: AddRemoveListener<EmittedType>;
addListener?: AddRemoveListener<EmittedType>;
addEventListener?: AddRemoveListener<EmittedType>;
off?: AddRemoveListener<EmittedType>;
removeListener?: AddRemoveListener<EmittedType>;
removeEventListener?: AddRemoveListener<EmittedType>;
}
export type FilterFunction<ElementType> = (element: ElementType) => boolean;
export type FilterFunction<ElementType extends unknown[]> = (...args: ElementType) => boolean;

@@ -33,16 +32,16 @@ export interface CancelablePromise<ResolveType> extends Promise<ResolveType> {

*/
declare function pEvent<EmittedType, EmittedTypeRest = EmittedType>(
emitter: Emitter<EmittedType, EmittedTypeRest>,
declare function pEvent<EmittedType extends unknown[]>(
emitter: Emitter<EmittedType>,
event: string | symbol | (string | symbol)[],
options: MultiArgumentsOptions<EmittedType | EmittedTypeRest>
): CancelablePromise<(EmittedType | EmittedTypeRest)[]>;
options: MultiArgumentsOptions<EmittedType>
): CancelablePromise<EmittedType>;
declare function pEvent<EmittedType>(
emitter: Emitter<EmittedType, unknown>,
emitter: Emitter<[EmittedType]>,
event: string | symbol | (string | symbol)[],
filter: FilterFunction<EmittedType>
filter: FilterFunction<[EmittedType]>
): CancelablePromise<EmittedType>;
declare function pEvent<EmittedType>(
emitter: Emitter<EmittedType, unknown>,
emitter: Emitter<[EmittedType]>,
event: string | symbol | (string | symbol)[],
options?: Options<EmittedType>
options?: Options<[EmittedType]>
): CancelablePromise<EmittedType>;

@@ -55,11 +54,11 @@

*/
export function multiple<EmittedType, EmittedTypeRest = EmittedType>(
emitter: Emitter<EmittedType, EmittedTypeRest>,
export function multiple<EmittedType extends unknown[]>(
emitter: Emitter<EmittedType>,
event: string | symbol | (string | symbol)[],
options: MultipleMultiArgumentsOptions<EmittedType | EmittedTypeRest>
): CancelablePromise<(EmittedType | EmittedTypeRest)[][]>;
options: MultipleMultiArgumentsOptions<EmittedType>
): CancelablePromise<EmittedType[]>;
export function multiple<EmittedType>(
emitter: Emitter<EmittedType, unknown>,
emitter: Emitter<[EmittedType]>,
event: string | symbol | (string | symbol)[],
options: MultipleOptions<EmittedType>
options: MultipleOptions<[EmittedType]>
): CancelablePromise<EmittedType[]>;

@@ -70,19 +69,19 @@

*/
export function iterator<EmittedType, EmittedTypeRest = EmittedType>(
emitter: Emitter<EmittedType, EmittedTypeRest>,
export function iterator<EmittedType extends unknown[]>(
emitter: Emitter<EmittedType>,
event: string | symbol | (string | symbol)[],
options: IteratorMultiArgumentsOptions<EmittedType | EmittedTypeRest>
): AsyncIterableIterator<(EmittedType | EmittedTypeRest)[]>;
options: IteratorMultiArgumentsOptions<EmittedType>
): AsyncIterableIterator<EmittedType>;
export function iterator<EmittedType>(
emitter: Emitter<EmittedType, unknown>,
emitter: Emitter<[EmittedType]>,
event: string | symbol | (string | symbol)[],
filter: FilterFunction<EmittedType>
filter: FilterFunction<[EmittedType]>
): AsyncIterableIterator<EmittedType>;
export function iterator<EmittedType>(
emitter: Emitter<EmittedType, unknown>,
emitter: Emitter<[EmittedType]>,
event: string | symbol | (string | symbol)[],
options?: IteratorOptions<EmittedType>
options?: IteratorOptions<[EmittedType]>
): AsyncIterableIterator<EmittedType>;
export interface Options<EmittedType> {
export interface Options<EmittedType extends unknown[]> {
/**

@@ -134,7 +133,7 @@ * Events that will reject the promise.

export interface MultiArgumentsOptions<EmittedType> extends Options<EmittedType> {
export interface MultiArgumentsOptions<EmittedType extends unknown[]> extends Options<EmittedType> {
readonly multiArgs: true;
}
export interface MultipleOptions<EmittedType> extends Options<EmittedType> {
export interface MultipleOptions<EmittedType extends unknown[]> extends Options<EmittedType> {
/**

@@ -181,7 +180,7 @@ * The number of times the event needs to be emitted before the promise resolves.

export interface MultipleMultiArgumentsOptions<EmittedType> extends MultipleOptions<EmittedType> {
export interface MultipleMultiArgumentsOptions<EmittedType extends unknown[]> extends MultipleOptions<EmittedType> {
readonly multiArgs: true;
}
export interface IteratorOptions<EmittedType> extends Options<EmittedType> {
export interface IteratorOptions<EmittedType extends unknown[]> extends Options<EmittedType> {
/**

@@ -202,5 +201,5 @@ * Maximum number of events for the iterator before it ends. When the limit is reached, the iterator will be marked as `done`. This option is useful to paginate events, for example, fetching 10 events per page.

export interface IteratorMultiArgumentsOptions<EmittedType>
export interface IteratorMultiArgumentsOptions<EmittedType extends unknown[]>
extends IteratorOptions<EmittedType> {
multiArgs: true;
}
{
"name": "p-event",
"version": "3.0.0",
"version": "4.0.0",
"description": "Promisify an event by waiting for it to be emitted",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc