Function propertyPathIterator
-
propertyPathIterator(
paths: PropertyPath | Iterable<PropertyPath, any, any>,
): IterableIterator<PropertyPath>Parameters
- paths: PropertyPath | Iterable<PropertyPath, any, any>
A single property path or an iterable containing property paths.
Returns IterableIterator<PropertyPath>
A validating iterator that yields each property path in source order.
Example
[...propertyPathIterator(['actor', 'name'])];
// [
// ['actor', 'name']
// ]To supply multiple dotted-string paths, use an iterable that is not itself a valid property path, such as a
Set:Example
[...propertyPathIterator(new Set([
'actor.name',
'actor.id'
]))];
// ['actor.name', 'actor.id']An outer array of exact array paths is also unambiguous because its entries are arrays rather than property keys:
Example
[...propertyPathIterator([
['actor', 'name'],
['actor', 'id']
])];
// [
// ['actor', 'name'],
// ['actor', 'id']
// ]Iterable entries are validated lazily as iteration advances. An invalid entry throws when that entry is reached; valid preceding entries may already have been yielded. An empty iterable produces an empty iterator.
Paths are yielded unchanged. Exact array paths are not normalized, copied, or frozen.
- paths: PropertyPath | Iterable<PropertyPath, any, any>
Returns a validating iterator for either one PropertyPath or an iterable of property paths.
A value satisfying isPropertyPath is always interpreted as one path before iterable detection occurs. This precedence is necessary because dotted strings and exact property-key arrays are themselves iterable.
Consequently, an array containing only property keys represents one exact path: