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

@stoplight/lifecycle

Package Overview
Dependencies
Maintainers
20
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.1.4 to 2.2.0

2

activatable/activatable.d.ts

@@ -10,3 +10,3 @@ export interface IMinimalActivatable {

protected _state: 'deactivated' | 'isActivating' | 'activated' | 'isDeactivating';
readonly state: "deactivated" | "isActivating" | "activated" | "isDeactivating";
get state(): "deactivated" | "isActivating" | "activated" | "isDeactivating";
activate(): Promise<void>;

@@ -13,0 +13,0 @@ deactivate(): Promise<void>;

@@ -5,3 +5,3 @@ import { IDisposable } from './types';

protected readonly disposables: IDisposable[];
readonly disposed: boolean;
get disposed(): boolean;
dispose(): void;

@@ -8,0 +8,0 @@ push(disposable: IDisposable): IDisposable;

import StrictEventEmitter from 'strict-event-emitter-types';
import { IDisposable } from '../disposable';
import { IEventEmitter, IEventEmitterInstance } from './types';
export interface IEventEmitter<E extends object> extends StrictEventEmitter<IEventEmitterInstance, E> {
createEmitGroup(): {
queueCount: number;
emit: IEventEmitter<E>['emit'];
flush: () => void;
reset: () => void;
};
}
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> {
private _emitter;
on(type: unknown, listener: Function): IDisposable;
emit(type: unknown, ...args: Array<unknown>): void;
readonly hasListeners: boolean;
emit(type: unknown, ...args: unknown[]): void;
get hasListeners(): boolean;
dispose(): void;
createEmitGroup(): {
queueCount: number;
emit: EventEmitter<E>['emit'];
flush: () => void;
reset: () => void;
};
}
export declare function createEventEmitter<T extends object>(): new () => StrictEventEmitter<IEventEmitterInstance, T, T, "addListener" | "addEventListener" | "removeListener" | "removeEventListener" | "once", "on" | "emit">;

@@ -33,2 +33,35 @@ "use strict";

}
createEmitGroup() {
const notifier = this;
const eventQueue = [];
let flushed = false;
return {
get queueCount() {
return eventQueue.length;
},
emit(event, ...args) {
if (flushed) {
notifier.emit(event, ...args);
}
else {
eventQueue.push([event, args]);
}
},
flush() {
for (const [event, args] of eventQueue) {
try {
notifier.emit(event, ...args);
}
catch (e) {
}
}
this.reset();
flushed = true;
},
reset() {
eventQueue.length = 0;
flushed = false;
},
};
}
}

@@ -35,0 +68,0 @@ exports.EventEmitter = EventEmitter;

export * from './emitter';
export * from './types';
{
"name": "@stoplight/lifecycle",
"version": "2.1.4",
"version": "2.2.0",
"description": "Event and disposable helpers.",

@@ -20,8 +20,7 @@ "keywords": [],

},
"peerDependencies": {},
"dependencies": {
"strict-event-emitter-types": "^2.0.0",
"wolfy87-eventemitter": "5.2.6"
"wolfy87-eventemitter": "~5.2.8"
},
"typings": "index.d.ts"
}

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