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

@stoplight/lifecycle

Package Overview
Dependencies
Maintainers
25
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stoplight/lifecycle - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

25

emitter/emitter.d.ts

@@ -1,21 +0,21 @@

import StrictEventEmitter from 'strict-event-emitter-types';
import { IDisposable } from '../disposable';
export interface IEmitGroup<E extends object> {
export declare type EventMap = {
[key: string]: (...args: any[]) => void;
};
export interface IEmitGroup<E extends EventMap> {
queueCount: number;
emit: EventEmitter<E>['emit'];
emit<P extends keyof E>(type: P, ...args: Parameters<E[P]>): void;
flush: () => void;
reset: () => void;
}
export interface IEventEmitter<E extends object> extends StrictEventEmitter<IEventEmitterInstance, E> {
export interface IEventEmitter<E extends EventMap> extends IDisposable {
on<P extends keyof E>(type: P, listener: E[P]): IDisposable;
emit<P extends keyof E>(type: P, ...args: Parameters<E[P]>): void;
hasListeners: boolean;
createEmitGroup(): IEmitGroup<E>;
}
export interface IEventEmitterInstance extends IDisposable {
on(type: number | string, listener: any): IDisposable;
emit<A extends unknown[] = unknown[]>(type: number | string, ...args: A): void;
hasListeners: boolean;
}
export declare class EventEmitter<E extends object> implements IEventEmitter<E> {
export declare class EventEmitter<E extends EventMap> implements IEventEmitter<E> {
private _emitter;
on(type: unknown, listener: Function): IDisposable;
emit(type: unknown, ...args: unknown[]): void;
on<P extends keyof E>(type: P, listener: E[P]): IDisposable;
emit<P extends keyof E>(type: P, ...args: Parameters<E[P]>): void;
get hasListeners(): boolean;

@@ -25,2 +25,1 @@ dispose(): void;

}
export declare function createEventEmitter<T extends object>(): new () => StrictEventEmitter<IEventEmitterInstance, T, T, "addListener" | "addEventListener" | "removeListener" | "removeEventListener" | "once", "emit" | "on">;

@@ -10,5 +10,13 @@ "use strict";

on(type, listener) {
this._emitter.on(String(type), listener);
const wrappedListener = (...args) => {
try {
listener(...args);
}
catch (ex) {
console.error(ex);
}
};
this._emitter.on(String(type), wrappedListener);
return disposable_1.createDisposable(() => {
this._emitter.off(String(type), listener);
this._emitter.off(String(type), wrappedListener);
});

@@ -69,7 +77,2 @@ }

exports.EventEmitter = EventEmitter;
function createEventEmitter() {
const TypedEmitter = EventEmitter;
return TypedEmitter;
}
exports.createEventEmitter = createEventEmitter;
//# sourceMappingURL=emitter.js.map
{
"name": "@stoplight/lifecycle",
"version": "2.3.0",
"version": "2.3.1",
"description": "Event and disposable helpers.",

@@ -21,3 +21,2 @@ "keywords": [],

"dependencies": {
"strict-event-emitter-types": "^2.0.0",
"wolfy87-eventemitter": "~5.2.8"

@@ -24,0 +23,0 @@ },

Sorry, the diff of this file is not supported yet

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