util
This commit is contained in:
parent
dcec17599a
commit
6204dd4c37
32
src/util/Util.js
Normal file
32
src/util/Util.js
Normal 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
3
src/util/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
Util: require('./Util')
|
||||
};
|
Loading…
Reference in New Issue
Block a user