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.1 to 2.3.2

3

emitter/emitter.d.ts

@@ -18,3 +18,4 @@ import { IDisposable } from '../disposable';

export declare class EventEmitter<E extends EventMap> implements IEventEmitter<E> {
private _emitter;
private readonly _emitter;
private readonly _registeredListeners;
on<P extends keyof E>(type: P, listener: E[P]): IDisposable;

@@ -21,0 +22,0 @@ emit<P extends keyof E>(type: P, ...args: Parameters<E[P]>): void;

@@ -8,4 +8,13 @@ "use strict";

this._emitter = new Emitter();
this._registeredListeners = new Map();
}
on(type, listener) {
let registeredListeners = this._registeredListeners.get(type);
if (registeredListeners === void 0) {
registeredListeners = new WeakSet();
this._registeredListeners.set(type, registeredListeners);
}
else if (registeredListeners.has(listener)) {
throw new Error(`Double-registered for '${type}' event.`);
}
const wrappedListener = (...args) => {

@@ -19,4 +28,7 @@ try {

};
registeredListeners.add(listener);
this._emitter.on(String(type), wrappedListener);
return disposable_1.createDisposable(() => {
var _a;
(_a = registeredListeners) === null || _a === void 0 ? void 0 : _a.delete(listener);
this._emitter.off(String(type), wrappedListener);

@@ -41,2 +53,3 @@ });

dispose() {
this._registeredListeners.clear();
this._emitter.removeAllListeners();

@@ -43,0 +56,0 @@ }

{
"name": "@stoplight/lifecycle",
"version": "2.3.1",
"version": "2.3.2",
"description": "Event and disposable helpers.",

@@ -5,0 +5,0 @@ "keywords": [],

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