Escritura de Codigo · JavaScript
Event Emitter
Minimal pub/sub in 15 lines.
Dificultad: Avanzado · 16 Lineas · Licencia: public-domain
class EventEmitter {
constructor() {
this.handlers = {};
}
on(event, fn) {
(this.handlers[event] ||= []).push(fn);
}
emit(event, ...args) {
for (const fn of this.handlers[event] || []) {
Tiempo0:00
Velocidad (WPM)0.0
Precisión100.0%
Errores0
Teclado en Vivo
Siguiente Tecla: C | Última Tecla: -
Progreso: 0.0%
º
1
2
3
4
5
6
7
8
9
0
'
¡
Q
W
E
R
T
Y
U
I
O
P
`
+
A
S
D
F
G
H
J
K
L
Ñ
´
Z
X
C
V
B
N
M
,
.
-
Espacio
Timed Test Leaderboard
Aún no hay resultados.