Home > @rushstack/lookup-by-path > IReadonlyLookupByPath > findChildPathFromSegments
IReadonlyLookupByPath.findChildPathFromSegments() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Searches for the item associated with childPathSegments, or the nearest ancestor of that path that has an associated item.
Signature:
findChildPathFromSegments(childPathSegments: Iterable<string>): TItem | undefined;
Parameters
Parameter | Type | Description |
|---|---|---|
childPathSegments | Iterable<string> |
Returns:
TItem | undefined
the found item, or undefined if no item was found
Example
const trie = new LookupByPath([['foo', 1], ['foo/bar', 2]]);
trie.findChildPathFromSegments(['foo', 'baz']); // returns 1
trie.findChildPathFromSegments(['foo','bar', 'baz']); // returns 2