Skip to content

Commit 8666b51

Browse files
committed
refactor: flush microtask queue implementation
1 parent 63187c4 commit 8666b51

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/flushMicroTasks.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import { setImmediate } from './helpers/timers';
22

3-
type Thenable<T> = { then: (callback: () => T) => unknown };
4-
5-
export function flushMicroTasks(): Thenable<void> {
6-
return {
7-
// using "thenable" instead of a Promise, because otherwise it breaks when
8-
// using "modern" fake timers
9-
then(resolve) {
10-
setImmediate(resolve);
11-
},
12-
};
3+
export function flushMicroTasks() {
4+
return new Promise((resolve) => setImmediate(resolve));
135
}

0 commit comments

Comments
 (0)