This class wraps a web address as an async tree, allowing it to be passed to functions such as
crawl.
API #
A tree of values obtained via HTTP/HTTPS calls. These values will be strings for HTTP responses with a MIME text type; otherwise they will be ArrayBuffer instances.
new SiteMap([href])
- href: string
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 get(key)
- key: any
Returns: Promise
Returns the value associated with the key, or undefined if there is none.
*keys()
Returns: AsyncIterableIterator
Returns an empty set of keys.
For a variation of SiteMap that can return the keys for a site route,
see ExplorableSiteMap.
async clear()
Returns: any
Remove all key/value entries from the map.
This method invokes the keys() and delete() methods.
async delete(key)
- key: any
Returns: Promise
Removes the entry for the given key, return true if an entry was removed and false if there was no entry for the key.
*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.
async set(key, value)
- key: any
- value: any
Returns: Promise
Sets the value for the given key.
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.