handles
Documentation / @wtf/platform-fs-memory / handles
A file system in memory, as handles of the WHATWG File System Standard: memoryDirectory, the root of a new one. It is the test double of a file system: a caller’s test gives it where the program is given a browser’s handle, or Node’s, and it behaves as the standard has a handle behave.
Each handle is a class of this module, made to be extended: a folder makes the handle of each
entry in it by one method, handleOf, which a class that extends them
overrides to make its own; and MemoryDirectoryHandle.root makes the root of the class it
is called of. A handle that extends them reaches what it is of by its protected members: the
fileSystem, its entries and what tells each change of them, the parts of its path, its
node() and where it is, and emit, which tells a change to each listener of the file system.
const root = memoryDirectory()const file = await root.getFileHandle('notes.md', { create: true })const writable = await file.createWritable()await writable.write('# Notes\n')await writable.close()