arbitrary-emitter
Advanced tools
Comparing version 0.10.0 to 0.10.1
@@ -8,3 +8,3 @@ 'use strict' | ||
function setActions (e, listeners) { | ||
const size = listeners.length | ||
let size = listeners.length | ||
if (!size) { | ||
@@ -17,4 +17,5 @@ events.delete(e.key) | ||
actions.set(e.key, opts => { | ||
for (let i = 0; i < size; i++) { | ||
listeners[i](opts) | ||
let size = listeners.length | ||
while (size > 0) { | ||
listeners[--size](opts) | ||
} | ||
@@ -32,3 +33,3 @@ }) | ||
if (listeners.indexOf(fn) === -1) { | ||
listeners.push(fn) | ||
listeners.unshift(fn) | ||
} | ||
@@ -35,0 +36,0 @@ setActions(e, listeners) |
{ | ||
"name": "arbitrary-emitter", | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"description": "Event emitter with ES6 Map sugar for modern browsers and node.js", | ||
@@ -5,0 +5,0 @@ "main": "arbitrary-emitter.js", |
@@ -6,3 +6,3 @@ arbitrary-emitter | ||
[![Build Status](https://travis-ci.org/jacoborus/arbitrary-emitter.svg?branch=master)](https://travis-ci.org/jacoborus/arbitrary-emitter) [![npm version](https://badge.fury.io/js/arbitrary-emitter.svg)](https://www.npmjs.com/package/arbitrary-emitter) | ||
[![Build Status](https://travis-ci.org/jacoborus/arbitrary-emitter.svg?branch=master)](https://travis-ci.org/jacoborus/arbitrary-emitter) [![npm version](https://badge.fury.io/js/arbitrary-emitter.svg)](https://www.npmjs.com/package/arbitrary-emitter) ![npm dependencies](https://david-dm.org/jacoborus/arbitrary-emitter.svg) | ||
@@ -9,0 +9,0 @@ **arbitrary-emitter** stores listeners and actions in Maps, this allows to use arbitrary values as keys for your listeners. |
@@ -105,1 +105,23 @@ 'use strict' | ||
}) | ||
test('remove listener while emitting', t => { | ||
const emitter = ae() | ||
const out = [] | ||
emitter.on('test', () => { | ||
out.push(1) | ||
}) | ||
emitter.once('test', () => { | ||
out.push('a') | ||
}) | ||
emitter.on('test', () => { | ||
out.push('finish') | ||
}) | ||
emitter.emit('test') | ||
emitter.emit('test') | ||
t.is(out[0], 1) | ||
t.is(out[1], 'a') | ||
t.is(out[2], 'finish') | ||
t.is(out[3], 1) | ||
t.is(out[4], 'finish') | ||
t.end() | ||
}) |
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
11190
189