New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

event-emitter-lite

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-emitter-lite - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

15

dist/amd/EventEmitter.d.ts

@@ -12,5 +12,2 @@ export declare enum EEventEmitterStatus {

}
export interface IEventEmitter {
done(p_onSuccess: Function, p_onError?: (err: IEventEmitterError) => any): void;
}
export interface IConfigEmitter {

@@ -24,3 +21,3 @@ }

}
export declare class EventEmitter<T, E = string> {
export declare class EventEmitter<GEmitType, GErrorType = string, GResolveType = any> {
private _events;

@@ -32,9 +29,9 @@ private _next_iterator;

constructor(config?: IConfigEmitter);
readonly emittedValue: T;
error(err: E): void;
emit(value: T): IEventEmitter;
readonly emittedValue: GEmitType;
error(err: GErrorType): void;
emit(value: GEmitType): GResolveType[];
private next(value);
private getRefId();
subscribe(handlerSucess: (value: T) => any, handlerError?: (value: E) => any): IEventSubscribe;
once(handlerSucess: (value: T) => any, handlerError?: (value: E) => any): IEventSubscribe;
subscribe(handlerSucess: (value: GEmitType) => any, handlerError?: (value: GErrorType) => any): IEventSubscribe;
once(handlerSucess: (value: GEmitType) => any, handlerError?: (value: GErrorType) => any): IEventSubscribe;
hasSubscribers(): boolean;

@@ -41,0 +38,0 @@ unsubscribeAll(): void;

@@ -46,2 +46,3 @@ define(["require", "exports"], function (require, exports) {

var hasCancel = this._cancel_next;
var _resolveValues = [];
if (hasCancel) {

@@ -53,3 +54,3 @@ this._cancel_next = false;

hasCancel = !this._events.every(function (_sub) {
_sub.handlerSucess(value);
_resolveValues.push(_sub.handlerSucess(value));
if (_sub.once) {

@@ -69,13 +70,3 @@ _toremove_1.push({ ref: _sub.ref });

;
this._lastvalue = value;
return {
done: function (p_onSuccess, p_onError) {
if (!hasCancel) {
p_onSuccess();
}
else if (p_onError) {
p_onError({ error: "error: there is a cancel solicitation", status: EEventEmitterStatus.CANCELED });
}
}
};
return _resolveValues;
};

@@ -82,0 +73,0 @@ EventEmitter.prototype.next = function (value) {

@@ -12,5 +12,2 @@ export declare enum EEventEmitterStatus {

}
export interface IEventEmitter {
done(p_onSuccess: Function, p_onError?: (err: IEventEmitterError) => any): void;
}
export interface IConfigEmitter {

@@ -24,3 +21,3 @@ }

}
export declare class EventEmitter<T, E = string> {
export declare class EventEmitter<GEmitType, GErrorType = string, GResolveType = any> {
private _events;

@@ -32,9 +29,9 @@ private _next_iterator;

constructor(config?: IConfigEmitter);
readonly emittedValue: T;
error(err: E): void;
emit(value: T): IEventEmitter;
readonly emittedValue: GEmitType;
error(err: GErrorType): void;
emit(value: GEmitType): GResolveType[];
private next(value);
private getRefId();
subscribe(handlerSucess: (value: T) => any, handlerError?: (value: E) => any): IEventSubscribe;
once(handlerSucess: (value: T) => any, handlerError?: (value: E) => any): IEventSubscribe;
subscribe(handlerSucess: (value: GEmitType) => any, handlerError?: (value: GErrorType) => any): IEventSubscribe;
once(handlerSucess: (value: GEmitType) => any, handlerError?: (value: GErrorType) => any): IEventSubscribe;
hasSubscribers(): boolean;

@@ -41,0 +38,0 @@ unsubscribeAll(): void;

@@ -45,2 +45,3 @@ "use strict";

var hasCancel = this._cancel_next;
var _resolveValues = [];
if (hasCancel) {

@@ -52,3 +53,3 @@ this._cancel_next = false;

hasCancel = !this._events.every(function (_sub) {
_sub.handlerSucess(value);
_resolveValues.push(_sub.handlerSucess(value));
if (_sub.once) {

@@ -68,13 +69,3 @@ _toremove_1.push({ ref: _sub.ref });

;
this._lastvalue = value;
return {
done: function (p_onSuccess, p_onError) {
if (!hasCancel) {
p_onSuccess();
}
else if (p_onError) {
p_onError({ error: "error: there is a cancel solicitation", status: EEventEmitterStatus.CANCELED });
}
}
};
return _resolveValues;
};

@@ -81,0 +72,0 @@ EventEmitter.prototype.next = function (value) {

8

package.json
{
"name": "event-emitter-lite",
"version": "1.3.0",
"version": "1.4.0",
"description": "simple event emitter to use with typescript and pure javascript no depences",
"scripts": {
"del:dist":"node_modules/.bin/del-cli dist",
"compile:commonjs": "node_modules/.bin/tsc --module commonjs --outDir dist/commonjs",
"compile:amd": "node_modules/.bin/tsc",
"build": "npm run compile:amd && npm run compile:commonjs",
"test": "npm run compile:commonjs && node example/test"
"build": "npm run del:dist && npm run compile:amd && npm run compile:commonjs",
"test": "npm run del:dist && npm run compile:commonjs && node example/test"
},

@@ -35,4 +36,5 @@ "main": "dist/commonjs/EventEmitter.js",

"devDependencies": {
"del-cli": "^1.1.0",
"typescript": "^2.6.2"
}
}

@@ -42,4 +42,9 @@ # event-emitter-lite

##### cancel by subscribe
##### cancel a event
``` javascript
onTest.cancel();
```
##### cancel a subscribe
``` javascript
egoistSubscribe.cancel();

@@ -83,3 +88,29 @@ ```

#### emiting a value (can do a promise) after a emit
``` javascript
onTest.subscribe(msg => {
//...do any thing with 'msg';
onTest.resolve('finished');
});
let afterEmit = onTest
.emit('its ok');
// 'finished'
```
with promise
``` javascript
onTest.subscribe(msg => {
//...do any thing with 'msg';
onTest.resolve(new Promise....);
});
onTest
.emit('its ok')
.then(() => console.log('finish!!!'));
```
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