generated from tc39/template-for-proposals
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
for "backend" part (node, deno, bun) because they all support node:fs
so it's can be simplified by
if (typeof process !== 'undefined') {
const fs = await import('node:fs/promises');
const bytes = await fs.readFile('./foo.jpeg');
console.log('File size:', bytes.length, 'bytes');
} else if (typeof window !== 'undefined') {
const response = await fetch('./foo.jpeg');
const bytes = await response.bytes();
console.log('File size:', bytes.byteLength, 'bytes');
}
Metadata
Metadata
Assignees
Labels
No labels