RoadmapShopEvents
Skip to main content

Home > @microsoft/rush-lib > LookupByPath > findChildPathFromSegments

LookupByPath.findChildPathFromSegments() method

This API is provided as a 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

ParameterTypeDescription
childPathSegmentsIterable<string>

Returns:

TItem | undefined

the found item, or undefined if no item was found

Example

const tree = new LookupByPath([['foo', 1], ['foo/bar', 2]]);
tree.findChildPathFromSegments(['foo', 'baz']); // returns 1
tree.findChildPathFromSegments(['foo','bar', 'baz']); // returns 2