Comparing version 2.0.1 to 2.0.2
@@ -23,5 +23,5 @@ define([], function() { return function Events(target){ | ||
target.emit = function(type){ | ||
var list = events[type] || empty, i=0, j; | ||
var e = events[type] || empty, list = e.length > 0 ? e.slice(0, e.length) : e, i=0, j; | ||
while(j=list[i++]) j[0].apply(j[1], empty.slice.call(arguments, 1)) | ||
}; | ||
}; }); |
@@ -1,1 +0,1 @@ | ||
define([],function(){return function(n){var t={},f=[];n=n||this,n.on=function(n,f,i){(t[n]=t[n]||[]).push([f,i])},n.off=function(n,i){n||(t={});for(var e=t[n]||f,o=e.length=i?e.length:0;o--;)i==e[o][0]&&e.splice(o,1)},n.emit=function(n){for(var i,e=t[n]||f,o=0;i=e[o++];)i[0].apply(i[1],f.slice.call(arguments,1))}}}); | ||
define([],function(){return function(n){var t={},e=[];n=n||this,n.on=function(n,e,i){(t[n]=t[n]||[]).push([e,i])},n.off=function(n,i){n||(t={});for(var f=t[n]||e,l=f.length=i?f.length:0;l--;)i==f[l][0]&&f.splice(l,1)},n.emit=function(n){for(var i,f=t[n]||e,l=f.length>0?f.slice(0,f.length):f,c=0;i=l[c++];)i[0].apply(i[1],e.slice.call(arguments,1))}}}); |
@@ -23,5 +23,5 @@ module.exports = function Events(target){ | ||
target.emit = function(type){ | ||
var list = events[type] || empty, i=0, j; | ||
var e = events[type] || empty, list = e.length > 0 ? e.slice(0, e.length) : e, i=0, j; | ||
while(j=list[i++]) j[0].apply(j[1], empty.slice.call(arguments, 1)) | ||
}; | ||
}; |
@@ -1,1 +0,1 @@ | ||
module.exports=function(n){var o={},t=[];n=n||this,n.on=function(n,t,e){(o[n]=o[n]||[]).push([t,e])},n.off=function(n,e){n||(o={});for(var f=o[n]||t,i=f.length=e?f.length:0;i--;)e==f[i][0]&&f.splice(i,1)},n.emit=function(n){for(var e,f=o[n]||t,i=0;e=f[i++];)e[0].apply(e[1],t.slice.call(arguments,1))}}; | ||
module.exports=function(n){var t={},e=[];n=n||this,n.on=function(n,e,l){(t[n]=t[n]||[]).push([e,l])},n.off=function(n,l){n||(t={});for(var o=t[n]||e,i=o.length=l?o.length:0;i--;)l==o[i][0]&&o.splice(i,1)},n.emit=function(n){for(var l,o=t[n]||e,i=o.length>0?o.slice(0,o.length):o,c=0;l=i[c++];)l[0].apply(l[1],e.slice.call(arguments,1))}}; |
@@ -23,5 +23,5 @@ function Events(target){ | ||
target.emit = function(type){ | ||
var list = events[type] || empty, i=0, j; | ||
var e = events[type] || empty, list = e.length > 0 ? e.slice(0, e.length) : e, i=0, j; | ||
while(j=list[i++]) j[0].apply(j[1], empty.slice.call(arguments, 1)) | ||
}; | ||
}; |
@@ -1,1 +0,1 @@ | ||
function Events(n){var t={},f=[];n=n||this,n.on=function(n,f,i){(t[n]=t[n]||[]).push([f,i])},n.off=function(n,i){n||(t={});for(var o=t[n]||f,c=o.length=i?o.length:0;c--;)i==o[c][0]&&o.splice(c,1)},n.emit=function(n){for(var i,o=t[n]||f,c=0;i=o[c++];)i[0].apply(i[1],f.slice.call(arguments,1))}} | ||
function Events(n){var t={},e=[];n=n||this,n.on=function(n,e,l){(t[n]=t[n]||[]).push([e,l])},n.off=function(n,l){n||(t={});for(var i=t[n]||e,c=i.length=l?i.length:0;c--;)l==i[c][0]&&i.splice(c,1)},n.emit=function(n){for(var l,i=t[n]||e,c=i.length>0?i.slice(0,i.length):i,f=0;l=c[f++];)l[0].apply(l[1],e.slice.call(arguments,1))}} |
{ | ||
"name": "minivents", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Tiny eventing for javascript", | ||
@@ -5,0 +5,0 @@ "main": "dist/minivents.commonjs.js", |
@@ -23,5 +23,5 @@ function Events(target){ | ||
target.emit = function(type){ | ||
var list = events[type] || empty, i=0, j; | ||
var e = events[type] || empty, list = e.length > 0 ? e.slice(0, e.length) : e, i=0, j; | ||
while(j=list[i++]) j[0].apply(j[1], empty.slice.call(arguments, 1)) | ||
}; | ||
} |
20
test.js
@@ -178,2 +178,22 @@ var assert = require('assert'), | ||
it('should result in registered callbacks being invoked event if one callback remove himself', function () { | ||
var bus = new Events(), | ||
called = 0, | ||
cascade = false, | ||
f1 = function () { called++ }, | ||
f2 = function () { called++ }, | ||
f3 = function () { called++ }, | ||
f4 = function () { bus.off('ping', f4); }, | ||
f5 = function () { called++ }; | ||
bus.on('ping', f1); | ||
bus.on('ping', f2); | ||
bus.on('ping', f3); | ||
bus.on('ping', f4); | ||
bus.on('ping', f5); | ||
bus.emit('ping'); | ||
assert.equal(called, 4); | ||
}); | ||
}); |
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
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
345
14593
15