Comparing version 1.0.0 to 2.0.0
/** | ||
* emmett - A custom events emitter for Node.js and the browser | ||
* @version v1.0.0 | ||
* @version v2.0.0 | ||
* @link https://github.com/jacomyal/emmett | ||
* @license MIT | ||
*/ | ||
(function(){"use strict";var t=function(){this._handlers={},this._handlersAll=[]};t.prototype.on=function(e,n){var r,s,h,i;if(1===arguments.length&&"object"==typeof arguments[0])for(h in arguments[0])t.prototype.on.call(this,h,arguments[0][h]);else if(1===arguments.length&&"function"==typeof arguments[0])this._handlersAll.push({handler:arguments[0]});else{if(2!==arguments.length||"function"!=typeof arguments[1])throw new Error("Wrong arguments.");for(i="string"==typeof e?[e]:e,r=0,s=i.length;r!==s;r+=1)h=i[r],h&&(this._handlers[h]||(this._handlers[h]=[]),this._handlers[h].push({handler:n}))}return this},t.prototype.off=function(t,e){var n,r,s,h,i,l,a,o="string"==typeof t?[t]:t;if(arguments.length){if(1===arguments.length&&"function"!=typeof o)for(n=0,r=o.length;n!==r;n+=1)delete this._handlers[o[n]];else if(1===arguments.length&&"function"==typeof o){e=arguments[0];for(i in this._handlers){for(l=[],n=0,r=this._handlers[i].length;n!==r;n+=1)this._handlers[i][n].handler!==e&&l.push(this._handlers[i][n]);this._handlers[i]=l}for(l=[],n=0,r=this._handlersAll.length;n!==r;n+=1)this._handlersAll[n].handler!==e&&l.push(this._handlersAll[n]);this._handlersAll=l}else if(2===arguments.length)for(n=0,r=o.length;n!==r;n+=1){if(a=o[n],this._handlers[a]){for(l=[],s=0,h=this._handlers[a].length;s!==h;s+=1)this._handlers[a][s].handler!==e&&l.push(this._handlers[a][s]);this._handlers[a]=l}this._handlers[a]&&0===this._handlers[a].length&&delete this._handlers[a]}}else{this._handlersAll=[];for(i in this._handlers)delete this._handlers[i]}return this},t.prototype.emit=function(t,e){var n,r,s,h,i,l,a,o,d="string"==typeof t?[t]:t;for(e=void 0===e?{}:e,n=0,r=d.length;n!==r;n+=1)if(o=d[n],a=(this._handlers[o]||[]).concat(this._handlersAll),a.length){for(l={type:o,data:e||{},target:this},i=[],s=0,h=a.length;s!==h;s+=1)a[s].handler(l),a[s].one||i.push(a[s]);this._handlers[o]=i}return this},t.prototype.binder=function(){var t=new e(this);return arguments.length&&t.on.apply(t,arguments),t};var e=function(e){t.call(this),this._emitter=e,this._enabled=!0};e.prototype.on=function(){return t.prototype.on.apply(this,arguments),this._enabled&&this._emitter.on.apply(this._emitter,arguments),this},e.prototype.off=function(){return t.prototype.off.apply(this,arguments),this._enabled&&this._emitter.off.apply(this._emitter,arguments),this},e.prototype.enable=function(){var t,e,n;if(this._enabled)return this;for(this._enabled=!0,e=this._handlersAll,n=e.length-1;n>=0;n--)this._emitter.on(e[n].handler);for(t in this._handlers)for(e=this._handlers[t],n=e.length-1;n>=0;n--)this._emitter.on(t,e[n].handler);return this},e.prototype.disable=function(){function t(t){return t.handler===r[e].handler}var e,n,r;if(!this._enabled)return this;for(r=this._emitter._handlersAll,e=r.length-1;e>=0;e--)this._handlersAll.find(t)&&r.splice(e,1);for(n in this._handlers)for(r=this._handlers[n],e=r.length-1;e>=0;e--)this._emitter.off(n,r[e].handler);return this._enabled=!1,this},t.version="1.0.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); | ||
(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); |
var gulp = require('gulp'), | ||
mocha = require('gulp-mocha'), | ||
jshint = require('gulp-jshint'), | ||
uglify = require('gulp-uglify'), | ||
rename = require('gulp-rename'), | ||
header = require('gulp-header'), | ||
jshint = require('gulp-jshint'), | ||
gjslint = require('gulp-gjslint'), | ||
browserify = require('gulp-browserify'), | ||
@@ -17,12 +18,16 @@ phantom = require('gulp-mocha-phantomjs'); | ||
var jshintConfig = { | ||
'-W055': true, | ||
'-W040': true, | ||
'-W064': true, | ||
node: true, | ||
browser: true | ||
}; | ||
'-W040': true, | ||
node: true, | ||
browser: true | ||
}, | ||
gjslintConfig = { | ||
flags: ['--nojsdoc', '--disable 211,212'] | ||
}; | ||
return gulp.src(indexFile) | ||
.pipe(jshint(jshintConfig)) | ||
.pipe(jshint.reporter('default')); | ||
.pipe(jshint.reporter('jshint-stylish')) | ||
.pipe(jshint.reporter('fail')) | ||
.pipe(gjslint(gjslintConfig)) | ||
.pipe(gjslint.reporter('console'), {fail: true}); | ||
}); | ||
@@ -29,0 +34,0 @@ |
{ | ||
"name": "emmett", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "A custom events emitter for Node.js and the browser", | ||
@@ -26,2 +26,3 @@ "main": "emmett.js", | ||
"gulp-browserify": "^0.5.0", | ||
"gulp-gjslint": "^0.1.4", | ||
"gulp-header": "^1.2.2", | ||
@@ -32,4 +33,5 @@ "gulp-jshint": "^1.8.6", | ||
"gulp-rename": "^1.2.0", | ||
"gulp-uglify": "^1.0.1" | ||
"gulp-uglify": "^1.0.1", | ||
"jshint-stylish": "^1.0.0" | ||
} | ||
} |
# Emmett - a custom events emitter for Node.js and the browser | ||
**version: 1.0.0** | ||
**version: 2.0.0** | ||
@@ -4,0 +4,0 @@ ## Description |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8107
10
66
1