(cb)
| 29 | const hooks = new Set(); |
| 30 | return { |
| 31 | hook(cb) { |
| 32 | hooks.add(cb); |
| 33 | return () => hooks.delete(cb); |
| 34 | }, |
| 35 | fire(...data) { |
| 36 | // Set#forEach correctly iterates the remainder even if current callback unhooks itself |
| 37 | hooks.forEach(cb => cb(...data)); |