You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A similar API shape for asynchronous file access would be great for interop between server/command-line and web code.
The API has a shape that allows streaming to a file, creating new files, opening an existing file, cloberring or not, iterating through directories, etc.
Adapted from the explainer, here's an example:
constdir_ref= ... // Some mechanism to obtain a directory handle TBD.forawait(const[name,entry]ofdir_ref){// Iterate through a directory.// entry is a FileSystemFileHandle or a FileSystemDirectoryHandle.// name is equal to entry.name}constnew_file=awaitdir_ref.getFile('foo.txt',{create: true});// Create a file.// Write to a file using an API resembling something like pwrite.constnew_file_writer=awaitnew_file.createWritable();awaitnew_file_writer.write(awaitfile_ref.getFile());awaitnew_file_writer.close();// Or using streams.constfile_ref=awaitdir_ref.getFile('foo.js');// Get a file from a directory.constcopy2=awaitdir_ref.getFile('foo2.txt',{create: true});(awaitfile_ref.getFile()).stream().pipeTo(awaitcopy2.createWritable());
...
The text was updated successfully, but these errors were encountered:
Consider implementing an asynchronous file system API.
On the Web, the Native File System API implements an API surface that provides file and directory access.
A similar API shape for asynchronous file access would be great for interop between server/command-line and web code.
The API has a shape that allows streaming to a file, creating new files, opening an existing file, cloberring or not, iterating through directories, etc.
Adapted from the explainer, here's an example:
The text was updated successfully, but these errors were encountered: