Skip to content

Commit ab52661

Browse files
Dirk LüthDirk Lüth
authored andcommitted
replace „await“ with „await Promise.resolve“ for safety
1 parent b093559 commit ab52661

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ async function applyEvent(listener, event, details) {
9292
let i = 0, item;
9393

9494
for(; (item = listener[i]); i++) {
95-
await item.callback.call(this, event, ...details);
96-
9795
if(item.remaining && !(item.remaining -= 1)) {
9896
this.off(item.identifier, item.callback);
9997
}
10098

99+
await Promise.resolve(item.callback.call(this, event, ...details));
100+
101101
if(event.isCanceled) {
102102
break;
103103
}
@@ -397,3 +397,14 @@ class Emitter {
397397
}
398398

399399
module.exports = initialize(Emitter);
400+
401+
/*
402+
(new Emitter())
403+
.on([ 'test1', 'test1' ], function(event) {
404+
console.log(event.name);
405+
406+
return new Promise((resolve) => { resolve(); });
407+
})
408+
.emit('test1')
409+
.emit('test1');
410+
*/

0 commit comments

Comments
 (0)