mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-01 20:06:43 +01:00
17 lines
384 B
TypeScript
17 lines
384 B
TypeScript
/*
|
|
* Miscellaneous utilities for asynchronous code.
|
|
*/
|
|
|
|
export function wait(ms: number): Promise<void> {
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
}
|
|
|
|
export function json(resp: Response): Promise<any> {
|
|
return resp.json();
|
|
}
|
|
|
|
export function u8Array(resp: Response): Promise<Uint8Array> {
|
|
return resp
|
|
.arrayBuffer()
|
|
.then(buf => new Uint8Array(buf));
|
|
}
|