Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "minivents", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"homepage": "https://github.com/allouis/minivents", | ||
@@ -5,0 +5,0 @@ "authors": [ |
define([], function() { return function Events(target){ | ||
var events = {}, empty = [], list, j, i; | ||
var events = {}, empty = []; | ||
target = target || this | ||
@@ -15,4 +15,4 @@ /** | ||
type || (events = {}) | ||
list = events[type] || empty, | ||
i = list.length = func ? list.length : 0 | ||
var list = events[type] || empty, | ||
i = list.length = func ? list.length : 0; | ||
while(i--) func == list[i][0] && list.splice(i,1) | ||
@@ -24,5 +24,5 @@ } | ||
target.emit = function(type){ | ||
list = events[type] || empty; i=0 | ||
var list = events[type] || empty, 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,i,e={},o=[];n=n||this,n.on=function(n,t,f){(e[n]=e[n]||[]).push([t,f])},n.off=function(n,f){for(n||(e={}),t=e[n]||o,i=t.length=f?t.length:0;i--;)f==t[i][0]&&t.splice(i,1)},n.emit=function(n){for(t=e[n]||o,i=0;f=t[i++];)f[0].apply(f[1],o.slice.call(arguments,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))}}}); |
module.exports = function Events(target){ | ||
var events = {}, empty = [], list, j, i; | ||
var events = {}, empty = []; | ||
target = target || this | ||
@@ -15,4 +15,4 @@ /** | ||
type || (events = {}) | ||
list = events[type] || empty, | ||
i = list.length = func ? list.length : 0 | ||
var list = events[type] || empty, | ||
i = list.length = func ? list.length : 0; | ||
while(i--) func == list[i][0] && list.splice(i,1) | ||
@@ -24,5 +24,5 @@ } | ||
target.emit = function(type){ | ||
list = events[type] || empty; i=0 | ||
var list = events[type] || empty, 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,e,f={},i=[];n=n||this,n.on=function(n,o,t){(f[n]=f[n]||[]).push([o,t])},n.off=function(n,t){for(n||(f={}),o=f[n]||i,e=o.length=t?o.length:0;e--;)t==o[e][0]&&o.splice(e,1)},n.emit=function(n){for(o=f[n]||i,e=0;t=o[e++];)t[0].apply(t[1],i.slice.call(arguments,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))}}; |
function Events(target){ | ||
var events = {}, empty = [], list, j, i; | ||
var events = {}, empty = []; | ||
target = target || this | ||
@@ -15,4 +15,4 @@ /** | ||
type || (events = {}) | ||
list = events[type] || empty, | ||
i = list.length = func ? list.length : 0 | ||
var list = events[type] || empty, | ||
i = list.length = func ? list.length : 0; | ||
while(i--) func == list[i][0] && list.splice(i,1) | ||
@@ -24,5 +24,5 @@ } | ||
target.emit = function(type){ | ||
list = events[type] || empty; i=0 | ||
var list = events[type] || empty, 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,i,o={},c=[];n=n||this,n.on=function(n,t,f){(o[n]=o[n]||[]).push([t,f])},n.off=function(n,f){for(n||(o={}),t=o[n]||c,i=t.length=f?t.length:0;i--;)f==t[i][0]&&t.splice(i,1)},n.emit=function(n){for(t=o[n]||c,i=0;f=t[i++];)f[0].apply(f[1],c.slice.call(arguments,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))}} |
{ | ||
"name": "minivents", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Tiny eventing for javascript", | ||
@@ -5,0 +5,0 @@ "main": "dist/minivents.commonjs.js", |
function Events(target){ | ||
var events = {}, empty = [], list, j, i; | ||
var events = {}, empty = []; | ||
target = target || this | ||
@@ -15,4 +15,4 @@ /** | ||
type || (events = {}) | ||
list = events[type] || empty, | ||
i = list.length = func ? list.length : 0 | ||
var list = events[type] || empty, | ||
i = list.length = func ? list.length : 0; | ||
while(i--) func == list[i][0] && list.splice(i,1) | ||
@@ -24,5 +24,5 @@ } | ||
target.emit = function(type){ | ||
list = events[type] || empty; i=0 | ||
var list = events[type] || empty, i=0, j; | ||
while(j=list[i++]) j[0].apply(j[1], empty.slice.call(arguments, 1)) | ||
}; | ||
} |
24
test.js
@@ -129,2 +129,3 @@ var assert = require('assert'), | ||
f3 = function () { called++ }; | ||
bus.on('ping', f1); | ||
@@ -155,2 +156,25 @@ bus.on('ping', f2); | ||
it('should result in registered callbacks being invoked with cascade', function () { | ||
var bus = new Events(), | ||
called = 0, | ||
cascade = false, | ||
f1 = function () { called++ }, | ||
f2 = function () { called++ }, | ||
f3 = function () { called++ }, | ||
f4 = function () { bus.emit('cascade'); }, | ||
f5 = function () { called++ }, | ||
f6 = function () { cascade = true; }; | ||
bus.on('ping', f1); | ||
bus.on('ping', f2); | ||
bus.on('ping', f3); | ||
bus.on('ping', f4); | ||
bus.on('ping', f5); | ||
bus.on('cascade', f6); | ||
bus.emit('ping'); | ||
assert.equal(called, 4); | ||
assert.equal(cascade, true); | ||
}); | ||
}); |
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
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
96491
16
328
0