chore: update public repo

This commit is contained in:
desu-bot 2025-09-14 21:52:13 +00:00
parent 728699b3ec
commit 96ca247fcb
No known key found for this signature in database
6 changed files with 261 additions and 133 deletions

View file

@ -21,3 +21,19 @@ export async function directoryExists(path: string): Promise<boolean> {
export function sanitizeFilename(filename: string) {
return filename.replace(/[/\\?%*:|"<>]/g, '_')
}
export async function writeWebStreamToFile(stream: ReadableStream<unknown>, path: string) {
const fd = await fsp.open(path, 'w+')
const writer = fd.createWriteStream()
for await (const chunk of stream as any) {
writer.write(chunk)
}
writer.end()
await new Promise<void>((resolve, reject) => {
writer.on('error', reject)
writer.on('finish', resolve)
})
}