refactor(simulator): switch to named exports
[e-mobility-charging-stations-simulator.git] / src / worker / WorkerUtils.ts
1 import chalk from 'chalk';
2
3 export class WorkerUtils {
4 private constructor() {
5 // This is intentional
6 }
7
8 public static async sleep(milliSeconds: number): Promise<NodeJS.Timeout> {
9 return new Promise((resolve) => setTimeout(resolve as () => void, milliSeconds));
10 }
11
12 public static defaultExitHandler = (code: number): void => {
13 if (code !== 0) {
14 console.error(chalk.red(`Worker exited with error exit code: ${code.toString()}`));
15 }
16 };
17
18 public static defaultErrorHandler = (error: Error): void => {
19 console.error(chalk.red('Worker errored: ', error));
20 };
21 }