Writable file streams and sync access handles can now be created with an optional "mode" parameter.
For sync access handles, "mode" can be "readwrite", "readonly", or "readwrite-unsafe". "readwrite" is the current behavior and the default if "mode" is not specified. Only one sync access handle can be open on a file handle in this mode. The two new modes, "readonly" and "readwrite-unsafe", are shared modes which are added to support multiple readers and writers.
For writable file streams, "mode" can be "exclusive" or "siloed". "siloed" is the current behavior and the default if "mode" is not specified. This mode allows multiple writers to clobber each other. The new "exclusive" mode is added to prevent this clobbering.
Add new locking modes to file handle primitives
Writable file streams and sync access handles can now be created with an optional "mode" parameter.
For sync access handles, "mode" can be "readwrite", "readonly", or "readwrite-unsafe". "readwrite" is the current behavior and the default if "mode" is not specified. Only one sync access handle can be open on a file handle in this mode. The two new modes, "readonly" and "readwrite-unsafe", are shared modes which are added to support multiple readers and writers.
For writable file streams, "mode" can be "exclusive" or "siloed". "siloed" is the current behavior and the default if "mode" is not specified. This mode allows multiple writers to clobber each other. The new "exclusive" mode is added to prevent this clobbering.
For a more detailed explanation, see Multiple Readers and Writers explainer: https://github.com/whatwg/fs/blob/main/proposals/MultipleReadersWriters.md.
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff