Class WeakPropertyPathMap<R, V>
Type Parameters
- R extends object
Weak root object type.
- V
Stored value type.
Constructors
constructor
-
Creates a weak property-path map with limits applied independently to every live root trie.
Because weak roots are not enumerable, aggregate limits across all live roots cannot be tracked without retaining those roots strongly. Constructor limits therefore apply per root while preserving normal weak-key collection semantics.
Type Parameters
- R extends object
Weak root object type.
- V
Stored value type.
Parameters
Optionaloptions: ConstructorPer-root storage and traversal limits accepted by PropertyPathMap.
Returns WeakPropertyPathMap<R, V>
- R extends object
Accessors
[toStringTag]
-
get "[toStringTag]"(): string
Provides the standard object tag used by
Object.prototype.toString.Returns string
Methods
clear
-
Removes every root association in constant time.
The prior
WeakMapand all path tries reachable only through it become eligible for garbage collection. Any iterator already returned by a matching or subtree method retains its direct reference to the corresponding path trie and may continue independently.Returns void
delete
-
Deletes one exact property path beneath a root.
If the removed path was the final entry beneath the root, the now-empty per-root trie is removed from the internal
WeakMap. Missing roots and missing exact paths returnfalse.Parameters
- root: R
Weak root object or function.
- path: PropertyPath
Dotted or exact property-key path.
Returns boolean
truewhen an exact path existed and was removed; otherwisefalse.Throws
If
pathis not a valid PropertyPath. - root: R
deleteRoot
-
Removes every path association beneath one known root.
Parameters
- root: R
Weak root object or function.
Returns boolean
truewhen the root had an associated path trie; otherwisefalse. - root: R
get
-
Retrieves the value stored at an exact structural path beneath a root.
undefinedmay mean either that the root / path is absent or thatundefinedis the stored value. Use has when that distinction matters.Parameters
- root: R
Weak root object or function.
- path: PropertyPath
Dotted or exact property-key path.
Returns V
Stored value or
undefinedwhen the root or exact path is absent.Throws
If
pathis not a valid PropertyPath. - root: R
has
-
Determines whether an exact path stores a value beneath a root.
Parameters
- root: R
Weak root object or function.
- path: PropertyPath
Dotted or exact property-key path.
Returns boolean
Whether the root exists and the exact path stores a value.
Throws
If
pathis not a valid PropertyPath. - root: R
hasRoot
-
Determines whether a root currently has at least one associated path.
Roots whose final path is deleted are removed eagerly, so a
trueresult always indicates a non-empty per-root trie.Parameters
- root: R
Weak root object or function.
Returns boolean
Whether the root currently owns a path trie.
- root: R
matchingEntries
-
matchingEntries(
root: R,
data: unknown,
options: Match & { includePropertyValue: true },
): IterableIterator<[readonly PropertyKey[], V, unknown]>Returns a trie-aware iterator of matching entries for one root.
Matching behavior, prefix pruning,
pathPrefix/stopAtbounds,maxDepth, result / visit budgets, array-index rules, inherited-property handling, optional candidate property values, and iteration order are delegated directly to PropertyPathMap.matchingEntries. A missing root behaves as an empty configured trie while still validating matching options during iterator consumption.Parameters
Returns IterableIterator<[readonly PropertyKey[], V, unknown]>
Iterator of canonical matching paths, mapped values, and optionally resolved candidate property values.
-
matchingEntries(
root: R,
data: unknown,
options?: Match & { includePropertyValue?: false },
): IterableIterator<[readonly PropertyKey[], V]>Returns a trie-aware iterator of matching entries for one root.
Matching behavior, prefix pruning,
pathPrefix/stopAtbounds,maxDepth, result / visit budgets, array-index rules, inherited-property handling, optional candidate property values, and iteration order are delegated directly to PropertyPathMap.matchingEntries. A missing root behaves as an empty configured trie while still validating matching options during iterator consumption.Parameters
Returns IterableIterator<[readonly PropertyKey[], V]>
Iterator of canonical matching paths, mapped values, and optionally resolved candidate property values.
-
matchingEntries(
root: R,
data: unknown,
options?: Match,
): IterableIterator<
[readonly PropertyKey[], V, unknown]
| [readonly PropertyKey[], V],
>Returns a trie-aware iterator of matching entries for one root.
Matching behavior, prefix pruning,
pathPrefix/stopAtbounds,maxDepth, result / visit budgets, array-index rules, inherited-property handling, optional candidate property values, and iteration order are delegated directly to PropertyPathMap.matchingEntries. A missing root behaves as an empty configured trie while still validating matching options during iterator consumption.Parameters
Returns IterableIterator<
[readonly PropertyKey[], V, unknown]
| [readonly PropertyKey[], V],
>Iterator of canonical matching paths, mapped values, and optionally resolved candidate property values.
matchingKeys
-
matchingKeys(
root: R,
data: unknown,
options?: MatchKeys,
): IterableIterator<readonly PropertyKey[]>Returns a trie-aware iterator of canonical matching paths for one root.
This delegates to PropertyPathMap.matchingKeys; see matchingEntries for complete matching, path-bound, and stop-bound semantics. A missing root produces an empty iterator while retaining option validation.
Parameters
Returns IterableIterator<readonly PropertyKey[]>
Iterator of canonical matching property paths.
matchingValues
-
matchingValues(
root: R,
data: unknown,
options: Match & { includePropertyValue: true },
): IterableIterator<[V, unknown]>Returns a trie-aware iterator of mapped values whose paths match a candidate value for one root.
By default, mapped values are yielded directly. Set
includePropertyValuetotrueto receive[mappedValue, propertyValue]tuples. Prefix and stop bounds are delegated to PropertyPathMap.matchingValues. A missing root produces an empty iterator while retaining normal option validation.Parameters
Returns IterableIterator<[V, unknown]>
Iterator of mapped values or mapped-value / candidate-property-value tuples.
-
matchingValues(
root: R,
data: unknown,
options?: Match & { includePropertyValue?: false },
): IterableIterator<V>Returns a trie-aware iterator of mapped values whose paths match a candidate value for one root.
By default, mapped values are yielded directly. Set
includePropertyValuetotrueto receive[mappedValue, propertyValue]tuples. Prefix and stop bounds are delegated to PropertyPathMap.matchingValues. A missing root produces an empty iterator while retaining normal option validation.Parameters
Returns IterableIterator<V>
Iterator of mapped values or mapped-value / candidate-property-value tuples.
-
Returns a trie-aware iterator of mapped values whose paths match a candidate value for one root.
By default, mapped values are yielded directly. Set
includePropertyValuetotrueto receive[mappedValue, propertyValue]tuples. Prefix and stop bounds are delegated to PropertyPathMap.matchingValues. A missing root produces an empty iterator while retaining normal option validation.Parameters
Returns IterableIterator<V | [V, unknown]>
Iterator of mapped values or mapped-value / candidate-property-value tuples.
set
-
Stores a value at an exact structural path beneath a weak root.
The per-root trie is created lazily on the first successful insertion. Invalid paths therefore cannot leave an empty root association behind. Existing roots reuse their current trie and retain all normal PropertyPathMap.set overwrite and insertion-order semantics.
Parameters
- root: R
Weak root object or function.
- path: PropertyPath
Dotted or exact property-key path.
- value: V
Value to store.
undefinedis valid.
Returns this
This weak map.
Throws
If
pathis not a valid PropertyPath. - root: R
subtreeEntries
-
Returns a bounded subtree entry iterator for one weak root.
Candidate-independent subtree behavior, absolute
pathPrefixselection, descendant pruning throughstopAt, relativemaxDepth, result / visit budgets, and deterministic trie order are delegated to PropertyPathMap.subtreeEntries. A missing root behaves as an empty configured trie while still validating all options during iterator consumption.Parameters
Returns IterableIterator<[readonly PropertyKey[], V]>
Iterator of canonical stored paths and mapped values.
subtreeKeys
-
Returns a bounded subtree key iterator for one weak root.
This delegates to PropertyPathMap.subtreeKeys. A missing root produces an empty iterator while retaining normal option validation.
Parameters
Returns IterableIterator<readonly PropertyKey[]>
Iterator of canonical stored property paths.
subtreeValues
-
Returns a bounded subtree value iterator for one weak root.
This delegates to PropertyPathMap.subtreeValues. A missing root produces an empty iterator while retaining normal option validation.
Parameters
Returns IterableIterator<V>
Iterator of mapped values.
Associates structural PropertyPath paths with values beneath weakly held root objects.
Each root is stored as a key in an internal
WeakMap, and each root value is a trie-based PropertyPathMap. This provides structural path lookup while allowing the root and its complete path map to become eligible for garbage collection when the root is no longer referenced elsewhere.Example
Weak collection constraints
Like
WeakMap, this collection cannot expose globalsize,entries,keys,values, or iteration because weak roots are intentionally not enumerable. Every query requires a known root object. clear is supported by replacing the internalWeakMapin constant time.Root and path semantics
undefinedis a valid stored value; use has to distinguish it from an absent path.WeakMapimmediately.Defensive limits
The constructor accepts the same storage and traversal limits as PropertyPathMap. Limits apply independently to each root trie, and a failed first insertion is validated before the root is retained. Aggregate limits across all roots are intentionally unavailable because tracking weak roots globally would require strong retention and violate weak-collection semantics.
Matching and subtree iterators support
maxDepth,maxResults, andmaxVisitsthrough the delegated PropertyPathMap options. Candidate getters and proxy traps may execute when matching requires property reads; their exceptions are intentionally propagated.Complexity
Root lookup is expected
O(1). Path operations retain theO(path length)behavior of PropertyPathMap. Trie-aware matching retains shared-prefix pruning and visits only candidate branches reachable from stored paths. Matching entry and value iterators may optionally include the property value resolved from the candidate object. Prefix-bounded matching and candidate-independent subtree iteration retain the corresponding behavior of PropertyPathMap.