arbitrary-emitter
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -14,13 +14,13 @@ 'use strict' | ||
} else if (size === 1) { | ||
actions.set(e.key, (a, b, c) => { | ||
actions.set(e.key, function () { | ||
const fn = listeners[0] | ||
if (fn) fn(a, b, c) | ||
if (fn) fn(...arguments) | ||
}) | ||
} else { | ||
actions.set(e.key, (a, b, c) => { | ||
actions.set(e.key, function () { | ||
e.running.push(listeners) | ||
let size = listeners.length | ||
while (size > 0) { | ||
const fn = listeners[--size] | ||
if (fn) fn(a, b, c) | ||
let s = size | ||
while (s > 0) { | ||
const fn = listeners[--s] | ||
if (fn) fn(...arguments) | ||
} | ||
@@ -27,0 +27,0 @@ e.running.pop() |
{ | ||
"name": "arbitrary-emitter", | ||
"version": "1.0.0", | ||
"description": "High performance event emitter for modern browsers in ~450 bytes", | ||
"version": "1.1.0", | ||
"description": "High performance event emitter in ~450 bytes", | ||
"main": "arbitrary-emitter.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -16,3 +16,3 @@ arbitrary-emitter | ||
- Be conventional: with conventional api (`on`, `off`, `once` and `emit`) | ||
- Be modern: it stores listeners in **ES6 maps**, so you can use any kind of value as key for the listeners (Seeusage example) | ||
- Be modern: it stores listeners in **ES6 maps**, so you can use any kind of value as key for the listeners (See usage example) | ||
@@ -19,0 +19,0 @@ It's written in vanilla ES6, so you will have to transpile it before using it in old browsers or node.js < v5.9 |
@@ -129,2 +129,3 @@ 'use strict' | ||
const f1 = () => out.push(1) | ||
const f3 = () => out.push(3) | ||
const f2 = () => { | ||
@@ -134,3 +135,2 @@ out.push(2) | ||
} | ||
const f3 = () => out.push(3) | ||
emitter.on('test', f1) | ||
@@ -137,0 +137,0 @@ emitter.on('test', f2) |
11572
7