Rewrite into TypeScript

This commit is contained in:
Wessel T
2019-08-01 16:49:14 +02:00
parent 9e7df46abb
commit 496cd5641c
29 changed files with 863 additions and 174 deletions

18
lib/util.ts Normal file
View File

@@ -0,0 +1,18 @@
/**
* Halt the event loop for `duration` seconds
*
* @param {number} [duration=1] - The duration in seconds to wait for
*/
export const sleep = (duration: number = 1): void => {
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, (duration * 1000));
};
/**
* Get all bits from `bits`
*
* @param {number} bits - The bits to get bits from
* @returns {number} - The found bits
*/
export const getBits = (bits: number): number => {
return (2 ** bits) - 1;
};