2021-03-11 21:04:09 +01:00
|
|
|
export async function sleep(timeout) {
|
|
|
|
return new Promise<void>( (resolve, reject) => setTimeout(() => resolve(), timeout));
|
|
|
|
}
|
2023-01-07 03:06:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates deep copy of an object
|
|
|
|
* @param obj
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
export function _cp(obj) {
|
2023-01-07 19:19:44 +01:00
|
|
|
try {
|
|
|
|
return JSON.parse(JSON.stringify(obj));
|
|
|
|
} catch (e) {
|
|
|
|
console.error('Failed to parse json. This probably means that the data we received was not an object. Will return data as-is');
|
|
|
|
console.error('data in:', obj, 'error:', e);
|
|
|
|
return obj;
|
|
|
|
}
|
2023-01-07 03:06:37 +01:00
|
|
|
}
|