Skip to content

Commit b9bdbf2

Browse files
committed
Return immediately if milliseconds is equal to 0
1 parent ecd0ae9 commit b9bdbf2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/util/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export function isPlainObj(value: unknown): value is JSONObject {
2020
* @param abortSignal An abort signal that can cancel the sleep if the signal is aborted.
2121
*/
2222
export function sleep(ms: number, abortSignal?: AbortSignal) {
23+
if (ms === 0) return;
24+
2325
return new Promise<void>((resolve) => {
2426
// Resolve early if the abort signal has been aborted already
2527
if (abortSignal?.aborted) {

0 commit comments

Comments
 (0)