This commit is contained in:
Erik 2022-11-09 11:23:34 +02:00
parent dcec17599a
commit 6204dd4c37
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
2 changed files with 35 additions and 0 deletions

32
src/util/Util.js Normal file
View File

@ -0,0 +1,32 @@
class Util {
constructor () {
throw new Error('Utility class, may not be instantiated.');
}
static get now () {
return Math.floor(Date.now() / 1000);
}
static wait (time) {
return new Promise((resolve) => {
setTimeout(resolve, time);
});
}
/**
* Fatally throw an error. Sends a signal to the parent process not to restart the process
*
* @static
* @param {Error} error Error to throw
* @memberof Util
*/
static fatal (error) {
process.send({ _fatal: true }, () => {
throw error;
});
}
}
module.exports = Util;

3
src/util/index.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
Util: require('./Util')
};