This class wraps a FileSystemDirectoryHandle as a read/write async map-based tree whose contents can be read and written via tree operations.
API #
A map of files backed by a browser-hosted file system such as the standard Origin Private File System or the (as of October 2023) experimental File System Access API.
new BrowserFileMap([directoryHandle])
- directoryHandle: FileSystemDirectoryHandle
Construct a map of files backed by a browser-hosted file system.
The directory handle can be obtained via any of the methods that return a FileSystemDirectoryHandle. If no directory is supplied, the tree is rooted at the Origin Private File System for the current site.
static async groupBy(iterable, keyFn)
- iterable: any
- keyFn: (element: any, index: any) => Promise
Returns: Promise
Groups items from an async iterable into an AsyncMap according to the keys returned by the given function.
async delete(key)
- key: any
Returns: unknown
Removes the entry for the given key, return true if an entry was removed and false if there was no entry for the key.
async get(key)
- key: any
Returns: unknown
Returns the value associated with the key, or undefined if there is none.
*keys()
Returns: unknown
Returns a new AsyncIterator object that contains the keys for each
element in the map in insertion order.
async set(key, value)
- key: any
- value: any
Returns: unknown
Sets the value for the given key.
async clear()
Returns: any
Remove all key/value entries from the map.
This method invokes the keys() and delete() methods.
*entries()
Returns: AsyncIterableIterator<[any, any]>
Returns a new AsyncIterator object that contains a two-member array of
[key, value] for each element in the map in insertion order.
This method invokes the keys() and get() methods.
async forEach(callback, [thisArg])
- callback: (value: any, key: any, thisArg: any) => Promise
- thisArg: any
Returns: any
Calls callback once for each key/value pair in the map, in insertion order.
This method invokes the entries() method.
async has(key)
- key: any
Returns: unknown
Returns true if the given key appears in the set returned by keys().
It doesn’t matter whether the value returned by get() is defined or not.
If the requested key has a trailing slash but has no associated value, but the alternate form with a slash does appear, this returns true.
parent
Type: AsyncMap
The parent of this node in a tree.
readOnly
Type: boolean
True if the object is read-only. This will be true if get() has been
overridden but set() and delete() have not.
size
Type: Promise
Returns the number of keys in the map.
The size property invokes an overridden keys() to ensure proper
behavior in subclasses. Because a subclass may not enforce a direct
correspondence between keys() and get(), the size may not reflect the
number of values that can be retrieved.
*values()
Returns: AsyncIterableIterator
Returns a new AsyncIterator object that contains the values for each
element in the map in insertion order.