From: Jérôme Benoit Date: Sat, 26 Oct 2024 21:11:36 +0000 (+0200) Subject: refactor: use micro tasks queue instead next tick one X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=95e17f676b7c1067ce40de914335e35afb862df8;p=e-mobility-charging-stations-simulator.git refactor: use micro tasks queue instead next tick one Signed-off-by: Jérôme Benoit --- diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 6acb470b..5ebe17ea 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -12,7 +12,7 @@ import { secondsToMilliseconds, } from 'date-fns' import { getRandomValues, randomBytes, randomUUID } from 'node:crypto' -import { env, nextTick } from 'node:process' +import { env } from 'node:process' import { is, isNotEmpty, type NonEmptyArray, type ReadonlyNonEmptyArray } from 'rambda' import { @@ -334,8 +334,8 @@ export const isArraySorted = (array: T[], compareFn: (a: T, b: T) => number): return true } -export const throwErrorInNextTick = (error: Error): void => { - nextTick(() => { +export const queueMicrotaskErrorThrowing = (error: Error): void => { + queueMicrotask(() => { throw error }) }