chore: move utils to package
This commit is contained in:
17
packages/utils/index.ts
Normal file
17
packages/utils/index.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user