Skip to content

Commit 73d08d1

Browse files
committed
Multiple parameters in event, protect ee internal structures
1 parent 897609a commit 73d08d1

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

JavaScript/examples/8-methods.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22

3-
const emitter = (l = {}, o) => (o = {
3+
const emitter = (l, o) => (l = {}, o = {
44
on: (n, f) => (l[n] = l[n] || []).push(f),
5-
emit: (n, d) => (l[n] || []).map(f => f(d)),
5+
emit: (n, ...d) => (l[n] || []).map(f => f(...d)),
66
once: (n, f, g) => o.on(n, g = (...a) => (f(...a), o.remove(n, g))),
7-
remove: (n, f, e = l[n] || []) => e.splice(e.indexOf(f), 1),
7+
remove: (n, f, e) => (e = l[n] || [], e.splice(e.indexOf(f), 1)),
88
clear: (n) => (n ? l[n] = [] : l = {}),
99
count: (n) => (l[n] || []).length
1010
});

0 commit comments

Comments
 (0)