Comparing version 1.1.5 to 1.1.6
@@ -1,2 +0,2 @@ | ||
function Events(target){ | ||
(this.window||module)[(this.window ? 'Events' : 'exports')] = function (target){ | ||
var events = {}; | ||
@@ -8,3 +8,3 @@ target = target || this | ||
target.on = function(type, func, ctx){ | ||
events[type] || (events[type] = []) | ||
events[type] = events[type] || [] | ||
events[type].push({f:func, c:ctx}) | ||
@@ -26,8 +26,5 @@ } | ||
var args = Array.apply([], arguments), | ||
list = events[args.shift()] || [], | ||
i = list.length, j | ||
for(j=0;j<i;j++) list[j].f.apply(list[j].c, args) | ||
list = events[args.shift()] || [], i=0, j | ||
for(;j=list[i++];) j.f.apply(j.c, args) | ||
}; | ||
} | ||
var u, module, cjs = module != u; | ||
(cjs ? module : window)[(cjs ? 'exports' : 'Events')] = Events; |
@@ -1,1 +0,1 @@ | ||
function Events(n){var t={};n=n||this,n.on=function(n,e,o){t[n]||(t[n]=[]),t[n].push({f:e,c:o})},n.off=function(n,e){n||(t={});for(var o=t[n]||[],f=o.length=e?o.length:0;f-->0;)e==o[f].f&&o.splice(f,1)},n.emit=function(){var n,e=Array.apply([],arguments),o=t[e.shift()]||[],f=o.length;for(n=0;f>n;n++)o[n].f.apply(o[n].c,e)}}var u,module,cjs=module!=u;(cjs?module:window)[cjs?"exports":"Events"]=Events; | ||
(this.window||module)[this.window?"Events":"exports"]=function(n){var t={};n=n||this,n.on=function(n,f,i){t[n]=t[n]||[],t[n].push({f:f,c:i})},n.off=function(n,f){n||(t={});for(var i=t[n]||[],o=i.length=f?i.length:0;o-->0;)f==i[o].f&&i.splice(o,1)},n.emit=function(){for(var n,f=Array.apply([],arguments),i=t[f.shift()]||[],o=0;n=i[o++];)n.f.apply(n.c,f)}}; |
{ | ||
"name": "minivents", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Tiny eventing for javascript", | ||
@@ -16,3 +16,7 @@ "main": "minivents.js", | ||
"events", | ||
"minivents" | ||
"minivents", | ||
"tiny", | ||
"event", | ||
"emitter", | ||
"eventemitter" | ||
], | ||
@@ -19,0 +23,0 @@ "author": { |
10
test.js
@@ -105,5 +105,11 @@ var assert = require('assert'), | ||
var bus = new Events(), | ||
f = function () { assert(true); }; | ||
bus.on('ping', f); | ||
called = 0, | ||
f1 = function () { called++ }, | ||
f2 = function () { called++ }, | ||
f3 = function () { called++ }; | ||
bus.on('ping', f1); | ||
bus.on('ping', f2); | ||
bus.on('ping', f3); | ||
bus.emit('ping'); | ||
assert(called, 3); | ||
}); | ||
@@ -110,0 +116,0 @@ |
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
9557
161