chore: move utils to package

This commit is contained in:
2023-02-10 17:52:50 +01:00
parent 0c829c88c5
commit 3727b6bb2b
26 changed files with 170 additions and 160 deletions

17
packages/utils/index.ts Normal file
View File

@@ -0,0 +1,17 @@
/**
* Create a delay
*/
export const sleep = (milliseconds: number) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
/**
* Check if an object is empty
*/
export const isEmpty = (obj: Object) => {
if (obj === null || obj === undefined) {
throw new Error('Error: Given object is not an object')
}
return Object.keys(obj).length === 0 && obj.constructor === Object
}