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

@yandeu/events

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yandeu/events - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

cjs/version.d.ts

3

cjs/index.d.ts
/**
* @package npmjs.com/package/@yandeu/events (events.min.js)
*
* @author Arnout Kazemier (https://github.com/3rd-Eden)

@@ -18,2 +20,3 @@ * @copyright Copyright (c) 2014 Arnout Kazemier

export declare class Events<EventMap extends ValidEventMap = any> {
static get VERSION(): string;
_events: Map<EventNames<EventMap>, any>;

@@ -20,0 +23,0 @@ _eventsCount: number;

"use strict";
/**
* @package npmjs.com/package/@yandeu/events (events.min.js)
*
* @author Arnout Kazemier (https://github.com/3rd-Eden)

@@ -18,2 +20,3 @@ * @copyright Copyright (c) 2014 Arnout Kazemier

exports.Events = void 0;
var version_1 = require("./version");
var EE = /** @class */ (function () {

@@ -52,2 +55,9 @@ function EE(fn, context, once) {

}
Object.defineProperty(Events, "VERSION", {
get: function () {
return version_1.VERSION;
},
enumerable: false,
configurable: true
});
Events.prototype.eventNames = function () {

@@ -54,0 +64,0 @@ return Array.from(this._events.keys());

/**
* @package npmjs.com/package/@yandeu/events (events.min.js)
*
* @author Arnout Kazemier (https://github.com/3rd-Eden)

@@ -18,2 +20,3 @@ * @copyright Copyright (c) 2014 Arnout Kazemier

export declare class Events<EventMap extends ValidEventMap = any> {
static get VERSION(): string;
_events: Map<EventNames<EventMap>, any>;

@@ -20,0 +23,0 @@ _eventsCount: number;

10

package.json
{
"name": "@yandeu/events",
"version": "0.0.4",
"version": "0.0.5",
"description": "Simplified and TypeScripted version of EventEmitter3@4.0.7",

@@ -23,2 +23,3 @@ "type": "commonjs",

"scripts": {
"prepareRelease": "npm install && npm run build",
"start": "npm run dev",

@@ -28,3 +29,4 @@ "dev": "npm run build && npm-run-all --parallel dev:*",

"dev:tsc-esm": "tsc --project tsconfig.json --watch",
"build": "npm-run-all build:* && node scripts/rename.cjs",
"build": "npm run prune && npm-run-all build:* && node scripts/rename.cjs",
"build:version": "npm run version",
"build:tsc-cjs": "tsc --project tsconfig.cjs.json",

@@ -34,6 +36,8 @@ "build:tsc-esm": "tsc --project tsconfig.json",

"test": "jest --collectCoverage",
"version": "extract version /src/version.ts",
"prune": "rimraf cjs esm umd",
"prepublishOnly": "npm run prune && npm run build && npm test"
"prepublishOnly": "npm run build && npm test"
},
"devDependencies": {
"@yandeu/extract": "^0.0.1",
"jest": "^26.6.3",

@@ -40,0 +44,0 @@ "npm-run-all": "^4.1.5",

@@ -41,5 +41,12 @@ # Events

```ts
// print the current version
console.log('Events VERSION: ', Events.VERSION)
```
## TypeScript
```ts
import { Events } from '@yandeu/events'
interface EventMap {

@@ -60,4 +67,20 @@ signal: () => void

```ts
import type { EventListener } from '@yandeu/events'
// typed listener
const listener: EventListener<EventMap, 'error'> = err => {
console.log('err:', err)
}
// add listener
events.on('error', listener)
// remove listener
// (once you don't need it anymore)
events.removeListener('error', listener)
```
## License
[MIT](LICENSE)

@@ -1,3 +0,5 @@

!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(function(){return(()=>{"use strict";var e={};return{465:function(e,t){
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(function(){return(()=>{"use strict";var e={465:function(e,t,n){
/**
* @package npmjs.com/package/@yandeu/events (events.min.js)
*
* @author Arnout Kazemier (https://github.com/3rd-Eden)

@@ -11,2 +13,2 @@ * @copyright Copyright (c) 2014 Arnout Kazemier

*/
var n=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Events=void 0;var r=function(e,t,n){void 0===n&&(n=!1),this.fn=e,this.context=t,this.once=n},o=function(e,t,n,o,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var i=new r(n,o||e,s);return e._events.has(t)?e._events.get(t).fn?e._events.set(t,[e._events.get(t),i]):e._events.get(t).push(i):(e._events.set(t,i),e._eventsCount++),e},s=function(e,t){0==--e._eventsCount?e._events=new Map:e._events.delete(t)},i=function(){function e(){this._events=new Map,this._eventsCount=0}return e.prototype.eventNames=function(){return Array.from(this._events.keys())},e.prototype.listeners=function(e){var t=this._events.get(e);if(!t)return[];if(t.fn)return[t.fn];for(var n=0,r=t.length,o=new Array(r);n<r;n++)o[n]=t[n].fn;return o},e.prototype.listenerCount=function(e){var t=this._events.get(e);return t?t.fn?1:t.length:0},e.prototype.emit=function(e){for(var t,r,o=[],s=1;s<arguments.length;s++)o[s-1]=arguments[s];if(!this._events.has(e))return!1;var i,f=this._events.get(e);if(f.fn)return f.once&&this.removeListener(e,f.fn,void 0,!0),(t=f.fn).call.apply(t,n([f.context],o)),!0;var u=f.length;for(i=0;i<u;i++)f[i].once&&this.removeListener(e,f[i].fn,void 0,!0),(r=f[i].fn).call.apply(r,n([f[i].context],o));return!0},e.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},e.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},e.prototype.removeListener=function(e,t,n,r){if(!this._events.has(e))return this;if(!t)return s(this,e),this;var o=this._events.get(e);if(o.fn)o.fn!==t||r&&!o.once||n&&o.context!==n||s(this,e);else{for(var i=0,f=[],u=o.length;i<u;i++)(o[i].fn!==t||r&&!o[i].once||n&&o[i].context!==n)&&f.push(o[i]);f.length?this._events.set(e,1===f.length?f[0]:f):s(this,e)}return this},e.prototype.removeAllListeners=function(e){return e?this._events.delete(e)&&s(this,e):(this._events=new Map,this._eventsCount=0),this},Object.defineProperty(e.prototype,"off",{get:function(){return this.removeListener},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"addListener",{get:function(){return this.on},enumerable:!1,configurable:!0}),e}();t.Events=i}}[465](0,e),e})()}));
var r=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,o=e.length;n<r;n++,o++)e[o]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Events=void 0;var o=n(314),s=function(e,t,n){void 0===n&&(n=!1),this.fn=e,this.context=t,this.once=n},i=function(e,t,n,r,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var i=new s(n,r||e,o);return e._events.has(t)?e._events.get(t).fn?e._events.set(t,[e._events.get(t),i]):e._events.get(t).push(i):(e._events.set(t,i),e._eventsCount++),e},f=function(e,t){0==--e._eventsCount?e._events=new Map:e._events.delete(t)},u=function(){function e(){this._events=new Map,this._eventsCount=0}return Object.defineProperty(e,"VERSION",{get:function(){return o.VERSION},enumerable:!1,configurable:!0}),e.prototype.eventNames=function(){return Array.from(this._events.keys())},e.prototype.listeners=function(e){var t=this._events.get(e);if(!t)return[];if(t.fn)return[t.fn];for(var n=0,r=t.length,o=new Array(r);n<r;n++)o[n]=t[n].fn;return o},e.prototype.listenerCount=function(e){var t=this._events.get(e);return t?t.fn?1:t.length:0},e.prototype.emit=function(e){for(var t,n,o=[],s=1;s<arguments.length;s++)o[s-1]=arguments[s];if(!this._events.has(e))return!1;var i,f=this._events.get(e);if(f.fn)return f.once&&this.removeListener(e,f.fn,void 0,!0),(t=f.fn).call.apply(t,r([f.context],o)),!0;var u=f.length;for(i=0;i<u;i++)f[i].once&&this.removeListener(e,f[i].fn,void 0,!0),(n=f[i].fn).call.apply(n,r([f[i].context],o));return!0},e.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},e.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},e.prototype.removeListener=function(e,t,n,r){if(!this._events.has(e))return this;if(!t)return f(this,e),this;var o=this._events.get(e);if(o.fn)o.fn!==t||r&&!o.once||n&&o.context!==n||f(this,e);else{for(var s=0,i=[],u=o.length;s<u;s++)(o[s].fn!==t||r&&!o[s].once||n&&o[s].context!==n)&&i.push(o[s]);i.length?this._events.set(e,1===i.length?i[0]:i):f(this,e)}return this},e.prototype.removeAllListeners=function(e){return e?this._events.delete(e)&&f(this,e):(this._events=new Map,this._eventsCount=0),this},Object.defineProperty(e.prototype,"off",{get:function(){return this.removeListener},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"addListener",{get:function(){return this.on},enumerable:!1,configurable:!0}),e}();t.Events=u},314:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.VERSION=void 0,t.VERSION="0.0.5"}},t={};return function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}(465)})()}));
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var s in n)("object"==typeof exports?exports:e)[s]=n[s]}}(self,(function(){return(()=>{"use strict";var e={d:(t,n)=>{for(var s in n)e.o(n,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:n[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{Events:()=>o});
/**
* @package npmjs.com/package/@yandeu/events (events.min.js)
*
* @author Arnout Kazemier (https://github.com/3rd-Eden)

@@ -11,2 +13,2 @@ * @copyright Copyright (c) 2014 Arnout Kazemier

*/
class n{constructor(e,t,n=!1){this.fn=e,this.context=t,this.once=n}}const s=(e,t,s,r,o)=>{if("function"!=typeof s)throw new TypeError("The listener must be a function");const i=new n(s,r||e,o);return e._events.has(t)?e._events.get(t).fn?e._events.set(t,[e._events.get(t),i]):e._events.get(t).push(i):(e._events.set(t,i),e._eventsCount++),e},r=(e,t)=>{0==--e._eventsCount?e._events=new Map:e._events.delete(t)};class o{constructor(){this._events=new Map,this._eventsCount=0}eventNames(){return Array.from(this._events.keys())}listeners(e){const t=this._events.get(e);if(!t)return[];if(t.fn)return[t.fn];for(var n=0,s=t.length,r=new Array(s);n<s;n++)r[n]=t[n].fn;return r}listenerCount(e){let t=this._events.get(e);return t?t.fn?1:t.length:0}emit(e,...t){if(!this._events.has(e))return!1;let n,s=this._events.get(e);if(s.fn)return s.once&&this.removeListener(e,s.fn,void 0,!0),s.fn.call(s.context,...t),!0;{let r=s.length;for(n=0;n<r;n++)s[n].once&&this.removeListener(e,s[n].fn,void 0,!0),s[n].fn.call(s[n].context,...t)}return!0}on(e,t,n){return s(this,e,t,n,!1)}once(e,t,n){return s(this,e,t,n,!0)}removeListener(e,t,n,s){if(!this._events.has(e))return this;if(!t)return r(this,e),this;let o=this._events.get(e);if(o.fn)o.fn!==t||s&&!o.once||n&&o.context!==n||r(this,e);else{for(var i=0,f=[],h=o.length;i<h;i++)(o[i].fn!==t||s&&!o[i].once||n&&o[i].context!==n)&&f.push(o[i]);f.length?this._events.set(e,1===f.length?f[0]:f):r(this,e)}return this}removeAllListeners(e){return e?this._events.delete(e)&&r(this,e):(this._events=new Map,this._eventsCount=0),this}get off(){return this.removeListener}get addListener(){return this.on}}return t})()}));
class n{constructor(e,t,n=!1){this.fn=e,this.context=t,this.once=n}}const s=(e,t,s,r,o)=>{if("function"!=typeof s)throw new TypeError("The listener must be a function");const i=new n(s,r||e,o);return e._events.has(t)?e._events.get(t).fn?e._events.set(t,[e._events.get(t),i]):e._events.get(t).push(i):(e._events.set(t,i),e._eventsCount++),e},r=(e,t)=>{0==--e._eventsCount?e._events=new Map:e._events.delete(t)};class o{constructor(){this._events=new Map,this._eventsCount=0}static get VERSION(){return"0.0.5"}eventNames(){return Array.from(this._events.keys())}listeners(e){const t=this._events.get(e);if(!t)return[];if(t.fn)return[t.fn];for(var n=0,s=t.length,r=new Array(s);n<s;n++)r[n]=t[n].fn;return r}listenerCount(e){let t=this._events.get(e);return t?t.fn?1:t.length:0}emit(e,...t){if(!this._events.has(e))return!1;let n,s=this._events.get(e);if(s.fn)return s.once&&this.removeListener(e,s.fn,void 0,!0),s.fn.call(s.context,...t),!0;{let r=s.length;for(n=0;n<r;n++)s[n].once&&this.removeListener(e,s[n].fn,void 0,!0),s[n].fn.call(s[n].context,...t)}return!0}on(e,t,n){return s(this,e,t,n,!1)}once(e,t,n){return s(this,e,t,n,!0)}removeListener(e,t,n,s){if(!this._events.has(e))return this;if(!t)return r(this,e),this;let o=this._events.get(e);if(o.fn)o.fn!==t||s&&!o.once||n&&o.context!==n||r(this,e);else{for(var i=0,f=[],h=o.length;i<h;i++)(o[i].fn!==t||s&&!o[i].once||n&&o[i].context!==n)&&f.push(o[i]);f.length?this._events.set(e,1===f.length?f[0]:f):r(this,e)}return this}removeAllListeners(e){return e?this._events.delete(e)&&r(this,e):(this._events=new Map,this._eventsCount=0),this}get off(){return this.removeListener}get addListener(){return this.on}}return t})()}));

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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