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

emmett

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emmett - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

emmett.js

4

emmett.min.js
/**
* emmett - A custom events emitter for Node.js and the browser
* @version v2.0.0
* @version v2.1.0
* @link https://github.com/jacomyal/emmett
* @license MIT
*/
(function(){"use strict";var t={once:"boolean"},e=function(){this._enabled=!0,this._children=[],this._handlers={},this._handlersAll=[]};e.prototype.on=function(n,r,i){var h,l,s,o,a,d;if("function"==typeof r){for(a="string"==typeof n?[n]:n,h=0,l=a.length;h!==l;h+=1)if(o=a[h]){this._handlers[o]||(this._handlers[o]=[]),d={handler:r};for(s in i||{}){if(!t[s])throw new Error('The option "'+s+'" is not recognized by Emmett.');d[s]=i[s]}this._handlers[o].push(d)}}else if(n&&"object"==typeof n&&!Array.isArray(n))for(o in n)e.prototype.on.call(this,o,n[o],i);else{if("function"!=typeof n)throw new Error("Wrong arguments.");d={handler:n};for(s in i||{}){if(!t[s])throw new Error('The option "'+s+'" is not recognized by Emmett.');d[s]=i[s]}this._handlersAll.push(d)}return this},e.prototype.once=function(){return this.on.apply(this,Array.prototype.splice.call(arguments,0).concat({once:!0})),this},e.prototype.off=function(t,e){var n,r,i,h,l,s,o,a="string"==typeof t?[t]:t;if(1===arguments.length&&"function"==typeof a){e=arguments[0];for(l in this._handlers){for(s=[],n=0,r=this._handlers[l].length;n!==r;n+=1)this._handlers[l][n].handler!==e&&s.push(this._handlers[l][n]);this._handlers[l]=s}for(s=[],n=0,r=this._handlersAll.length;n!==r;n+=1)this._handlersAll[n].handler!==e&&s.push(this._handlersAll[n]);this._handlersAll=s}else if(2===arguments.length)for(n=0,r=a.length;n!==r;n+=1){if(o=a[n],this._handlers[o]){for(s=[],i=0,h=this._handlers[o].length;i!==h;i+=1)this._handlers[o][i].handler!==e&&s.push(this._handlers[o][i]);this._handlers[o]=s}this._handlers[o]&&0===this._handlers[o].length&&delete this._handlers[o]}return this},e.prototype.unbindAll=function(){var t;this._handlersAll=[];for(t in this._handlers)delete this._handlers[t];return this},e.prototype.emit=function(t,e){var n,r,i,h,l,s,o,a,d,f="string"==typeof t?[t]:t;if(!this._enabled)return this;for(e=void 0===e?{}:e,n=0,r=f.length;n!==r;n+=1)if(d=f[n],a=(this._handlers[d]||[]).concat(this._handlersAll),a.length){for(s={type:d,data:e||{},target:this},l=[],i=0,h=a.length;i!==h;i+=1)a[i].handler.call(this,s),a[i].once||l.push(a[i]);this._handlers[d]=l}for(n=0,r=this._children.length;n!==r;n+=1)o=this._children[n],o.emit.apply(o,arguments);return this},e.prototype.child=function(){var t=this,n=new e;return n.on("emmett:kill",function(){if(t._children)for(var e=0,r=t._children.length;r>e;e++)if(t._children[e]===n){t._children.splice(e,1);break}}),this._children.push(n),n},e.prototype.kill=function(){if(this.emit("emmett:kill"),this.unbindAll(),this._handlers=null,this._handlersAll=null,this._enabled=!1,this._children)for(var t=0,e=this._children.length;e>t;t++)this._children[t].kill();this._children=null},e.prototype.disable=function(){return this._enabled=!1,this},e.prototype.enable=function(){return this._enabled=!0,this},e.version="2.0.0","undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=e),exports.Emitter=e):"function"==typeof define&&define.amd?define("emmett",[],function(){return e}):this.Emitter=e}).call(this);
(function(){"use strict";var e={once:"boolean",scope:"object"},t=function(){this._enabled=!0,this._children=[],this._handlers={},this._handlersAll=[]};t.prototype.on=function(n,r,i){var h,s,l,o,d,a;if("function"==typeof r){for(d="string"==typeof n?[n]:n,h=0,s=d.length;h!==s;h+=1)if(o=d[h]){this._handlers[o]||(this._handlers[o]=[]),a={handler:r};for(l in i||{}){if(!e[l])throw new Error('The option "'+l+'" is not recognized by Emmett.');a[l]=i[l]}this._handlers[o].push(a)}}else if(n&&"object"==typeof n&&!Array.isArray(n))for(o in n)t.prototype.on.call(this,o,n[o],i);else{if("function"!=typeof n)throw new Error("Wrong arguments.");a={handler:n};for(l in i||{}){if(!e[l])throw new Error('The option "'+l+'" is not recognized by Emmett.');a[l]=i[l]}this._handlersAll.push(a)}return this},t.prototype.once=function(e,t,n){if("function"==typeof t)n=n||{},n.once=!0,this.on(e,t,n);else{if((!e||"object"!=typeof e||Array.isArray(e))&&"function"!=typeof e)throw new Error("Wrong arguments.");t=t||{},t.once=!0,this.on(e,t)}return this},t.prototype.off=function(e,t){var n,r,i,h,s,l,o,d="string"==typeof e?[e]:e;if(1===arguments.length&&"function"==typeof d){t=arguments[0];for(s in this._handlers){for(l=[],n=0,r=this._handlers[s].length;n!==r;n+=1)this._handlers[s][n].handler!==t&&l.push(this._handlers[s][n]);this._handlers[s]=l}for(l=[],n=0,r=this._handlersAll.length;n!==r;n+=1)this._handlersAll[n].handler!==t&&l.push(this._handlersAll[n]);this._handlersAll=l}else if(2===arguments.length)for(n=0,r=d.length;n!==r;n+=1){if(o=d[n],this._handlers[o]){for(l=[],i=0,h=this._handlers[o].length;i!==h;i+=1)this._handlers[o][i].handler!==t&&l.push(this._handlers[o][i]);this._handlers[o]=l}this._handlers[o]&&0===this._handlers[o].length&&delete this._handlers[o]}return this},t.prototype.unbindAll=function(){var e;this._handlersAll=[];for(e in this._handlers)delete this._handlers[e];return this},t.prototype.emit=function(e,t){var n,r,i,h,s,l,o,d,a,f="string"==typeof e?[e]:e;if(!this._enabled)return this;for(t=void 0===t?{}:t,n=0,r=f.length;n!==r;n+=1)if(a=f[n],d=(this._handlers[a]||[]).concat(this._handlersAll),d.length){for(l={type:a,data:t||{},target:this},s=[],i=0,h=d.length;i!==h;i+=1)d[i].handler.call("scope"in d[i]?d[i].scope:this,l),d[i].once||s.push(d[i]);this._handlers[a]=s}for(n=0,r=this._children.length;n!==r;n+=1)o=this._children[n],o.emit.apply(o,arguments);return this},t.prototype.child=function(){var e=this,n=new t;return n.on("emmett:kill",function(){if(e._children)for(var t=0,r=e._children.length;r>t;t++)if(e._children[t]===n){e._children.splice(t,1);break}}),this._children.push(n),n},t.prototype.kill=function(){if(this.emit("emmett:kill"),this.unbindAll(),this._handlers=null,this._handlersAll=null,this._enabled=!1,this._children)for(var e=0,t=this._children.length;t>e;e++)this._children[e].kill();this._children=null},t.prototype.disable=function(){return this._enabled=!1,this},t.prototype.enable=function(){return this._enabled=!0,this},t.version="2.1.0","undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=t),exports.Emitter=t):"function"==typeof define&&define.amd?define("emmett",[],function(){return t}):this.Emitter=t}).call(this);
{
"name": "emmett",
"version": "2.0.0",
"version": "2.1.0",
"description": "A custom events emitter for Node.js and the browser",

@@ -5,0 +5,0 @@ "main": "emmett.js",

# Emmett - a custom events emitter for Node.js and the browser
**version: 2.0.0**
**version: 2.1.0**

@@ -4,0 +4,0 @@ ## Description

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