@rushstack/lookup-by-path 0.7.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -1,6 +1,30 @@
1
1
  {
2
2
  "name": "@rushstack/lookup-by-path",
3
3
  "entries": [
4
+ {
5
+ "version": "0.7.3",
6
+ "tag": "@rushstack/lookup-by-path_v0.7.3",
7
+ "date": "Fri, 01 Aug 2025 00:12:49 GMT",
8
+ "comments": {
9
+ "dependency": [
10
+ {
11
+ "comment": "Updating dependency \"@rushstack/heft\" to `0.74.2`"
12
+ }
13
+ ]
14
+ }
15
+ },
16
+ {
17
+ "version": "0.7.2",
18
+ "tag": "@rushstack/lookup-by-path_v0.7.2",
19
+ "date": "Wed, 23 Jul 2025 20:55:57 GMT",
20
+ "comments": {
21
+ "dependency": [
22
+ {
23
+ "comment": "Updating dependency \"@rushstack/heft\" to `0.74.1`"
24
+ }
25
+ ]
26
+ }
27
+ },
4
28
  {
5
29
  "version": "0.7.1",
6
30
  "tag": "@rushstack/lookup-by-path_v0.7.1",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Change Log - @rushstack/lookup-by-path
2
2
 
3
- This log was last generated on Sat, 21 Jun 2025 00:13:15 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 01 Aug 2025 00:12:49 GMT and should not be manually modified.
4
+
5
+ ## 0.7.3
6
+ Fri, 01 Aug 2025 00:12:49 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 0.7.2
11
+ Wed, 23 Jul 2025 20:55:57 GMT
12
+
13
+ _Version update only_
4
14
 
5
15
  ## 0.7.1
6
16
  Sat, 21 Jun 2025 00:13:15 GMT
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.8"
8
+ "packageVersion": "7.52.9"
9
9
  }
10
10
  ]
11
11
  }
@@ -1 +1 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YAAY,CAAC,KAAK,CAAC,GAAG,SAAS;IAIlC;;OAEG;IACI,yBAAyB,CAAC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,KAAK,GAAG,SAAS;IAqBxF;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,GAAE,MAAuB,GAAG,OAAO;IAKpE;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,GAAE,MAAuB,GAAG,KAAK,GAAG,SAAS;IAK9E;;OAEG;IACI,YAAY,CAAC,KAAK,EACvB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9B,SAAS,GAAE,MAAuB,GACjC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAmBjC;;OAEG;IACK,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,SAAS,GAAE,MAAuB,GAAG,gBAAgB,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAyBtG;;OAEG;IACI,CAAC,MAAM,CAAC,QAAQ,CAAC,CACtB,KAAK,CAAC,EAAE,MAAM,EACd,SAAS,GAAE,MAAuB,GACjC,gBAAgB,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAIpC;;;;;;;OAOG;IACH,OAAO,CAAC,uBAAuB;IAiC/B;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;CAiB1B"}
@@ -268,7 +268,6 @@ class LookupByPath {
268
268
  }
269
269
  const stack = [[query !== null && query !== void 0 ? query : '', root]];
270
270
  while (stack.length > 0) {
271
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
272
271
  const [prefix, node] = stack.pop();
273
272
  if (node.value !== undefined) {
274
273
  yield [prefix, node.value];
@@ -1 +1 @@
1
- {"version":3,"file":"LookupByPath.js","sourceRoot":"","sources":["../src/LookupByPath.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2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,EAAE,IAAI,YAAY,CAAC,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;YACzE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnB,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,MAAM,KAAK,GAAqC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC1E,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,IAAI,GAAG,KAAK,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/XD,oCA+XC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * A node in the path trie used in LookupByPath\n */\ninterface IPathTrieNode<TItem extends {}> {\n /**\n * The value that exactly matches the current relative path\n */\n value: TItem | undefined;\n\n /**\n * Child nodes by subfolder\n */\n children: Map<string, IPathTrieNode<TItem>> | undefined;\n}\n\n/**\n * Readonly view of a node in the path trie used in LookupByPath\n *\n * @remarks\n * This interface is used to facilitate parallel traversals for comparing two `LookupByPath` instances.\n *\n * @beta\n */\nexport interface IReadonlyPathTrieNode<TItem extends {}> {\n /**\n * The value that exactly matches the current relative path\n */\n readonly value: TItem | undefined;\n\n /**\n * Child nodes by subfolder\n */\n readonly children: ReadonlyMap<string, IReadonlyPathTrieNode<TItem>> | undefined;\n}\n\ninterface IPrefixEntry {\n /**\n * The prefix that was matched\n */\n prefix: string;\n\n /**\n * The index of the first character after the matched prefix\n */\n index: number;\n}\n\n/**\n * Object containing both the matched item and the start index of the remainder of the query.\n *\n * @beta\n */\nexport interface IPrefixMatch<TItem extends {}> {\n /**\n * The item that matched the prefix\n */\n value: TItem;\n\n /**\n * The index of the first character after the matched prefix\n */\n index: number;\n\n /**\n * The last match found (with a shorter prefix), if any\n */\n lastMatch?: IPrefixMatch<TItem>;\n}\n\n/**\n * The readonly component of `LookupByPath`, to simplify unit testing.\n *\n * @beta\n */\nexport interface IReadonlyLookupByPath<TItem extends {}> extends Iterable<[string, TItem]> {\n /**\n * Searches for the item associated with `childPath`, or the nearest ancestor of that path that\n * has an associated item.\n *\n * @returns the found item, or `undefined` if no item was found\n *\n * @example\n * ```ts\n * const trie = new LookupByPath([['foo', 1], ['foo/bar', 2]]);\n * trie.findChildPath('foo/baz'); // returns 1\n * trie.findChildPath('foo/bar/baz'); // returns 2\n * ```\n */\n findChildPath(childPath: string, delimiter?: string): TItem | undefined;\n\n /**\n * Searches for the item for which the recorded prefix is the longest matching prefix of `query`.\n * Obtains both the item and the length of the matched prefix, so that the remainder of the path can be\n * extracted.\n *\n * @returns the found item and the length of the matched prefix, or `undefined` if no item was found\n *\n * @example\n * ```ts\n * const trie = new LookupByPath([['foo', 1], ['foo/bar', 2]]);\n * trie.findLongestPrefixMatch('foo/baz'); // returns { item: 1, index: 3 }\n * trie.findLongestPrefixMatch('foo/bar/baz'); // returns { item: 2, index: 7 }\n * ```\n */\n findLongestPrefixMatch(query: string, delimiter?: string): IPrefixMatch<TItem> | undefined;\n\n /**\n * Searches for the item associated with `childPathSegments`, or the nearest ancestor of that path that\n * has an associated item.\n *\n * @returns the found item, or `undefined` if no item was found\n *\n * @example\n * ```ts\n * const trie = new LookupByPath([['foo', 1], ['foo/bar', 2]]);\n * trie.findChildPathFromSegments(['foo', 'baz']); // returns 1\n * trie.findChildPathFromSegments(['foo','bar', 'baz']); // returns 2\n * ```\n */\n findChildPathFromSegments(childPathSegments: Iterable<string>): TItem | undefined;\n\n /**\n * Determines if an entry exists exactly at the specified path.\n *\n * @returns `true` if an entry exists at the specified path, `false` otherwise\n */\n has(query: string, delimiter?: string): boolean;\n\n /**\n * Retrieves the entry that exists exactly at the specified path, if any.\n *\n * @returns The entry that exists exactly at the specified path, or `undefined` if no entry exists.\n */\n get(query: string, delimiter?: string): TItem | undefined;\n\n /**\n * Gets the number of entries in this trie.\n *\n * @returns The number of entries in this trie.\n */\n get size(): number;\n\n /**\n * @returns The root node of the trie, corresponding to the path ''\n */\n get tree(): IReadonlyPathTrieNode<TItem>;\n\n /**\n * Iterates over the entries in this trie.\n *\n * @param query - An optional query. If specified only entries that start with the query will be returned.\n *\n * @returns An iterator over the entries under the specified query (or the root if no query is specified).\n * @remarks\n * Keys in the returned iterator use the provided delimiter to join segments.\n * Iteration order is not specified.\n * @example\n * ```ts\n * const trie = new LookupByPath([['foo', 1], ['foo/bar', 2]]);\n * [...trie.entries(undefined, ',')); // returns [['foo', 1], ['foo,bar', 2]]\n * ```\n */\n entries(query?: string, delimiter?: string): IterableIterator<[string, TItem]>;\n\n /**\n * Iterates over the entries in this trie.\n *\n * @param query - An optional query. If specified only entries that start with the query will be returned.\n *\n * @returns An iterator over the entries under the specified query (or the root if no query is specified).\n * @remarks\n * Keys in the returned iterator use the provided delimiter to join segments.\n * Iteration order is not specified.\n */\n [Symbol.iterator](query?: string, delimiter?: string): IterableIterator<[string, TItem]>;\n\n /**\n * Groups the provided map of info by the nearest entry in the trie that contains the path. If the path\n * is not found in the trie, the info is ignored.\n *\n * @returns The grouped info, grouped by the nearest entry in the trie that contains the path\n *\n * @param infoByPath - The info to be grouped, keyed by path\n */\n groupByChild<TInfo>(infoByPath: Map<string, TInfo>, delimiter?: string): Map<TItem, Map<string, TInfo>>;\n}\n\n/**\n * This class is used to associate path-like-strings, such as those returned by `git` commands,\n * with entities that correspond with ancestor folders, such as Rush Projects or npm packages.\n *\n * It is optimized for efficiently locating the nearest ancestor path with an associated value.\n *\n * It is implemented as a Trie (https://en.wikipedia.org/wiki/Trie) data structure, with each edge\n * being a path segment.\n *\n * @example\n * ```ts\n * const trie = new LookupByPath([['foo', 1], ['bar', 2], ['foo/bar', 3]]);\n * trie.findChildPath('foo'); // returns 1\n * trie.findChildPath('foo/baz'); // returns 1\n * trie.findChildPath('baz'); // returns undefined\n * trie.findChildPath('foo/bar/baz'); returns 3\n * trie.findChildPath('bar/foo/bar'); returns 2\n * ```\n * @beta\n */\nexport class LookupByPath<TItem extends {}> implements IReadonlyLookupByPath<TItem> {\n /**\n * The delimiter used to split paths\n */\n public readonly delimiter: string;\n\n /**\n * The root node of the trie, corresponding to the path ''\n */\n private readonly _root: IPathTrieNode<TItem>;\n\n /**\n * The number of entries in this trie.\n */\n private _size: number;\n\n /**\n * Constructs a new `LookupByPath`\n *\n * @param entries - Initial path-value pairs to populate the trie.\n */\n public constructor(entries?: Iterable<[string, TItem]>, delimiter?: string) {\n this._root = {\n value: undefined,\n children: undefined\n };\n\n this.delimiter = delimiter ?? '/';\n this._size = 0;\n\n if (entries) {\n for (const [path, item] of entries) {\n this.setItem(path, item);\n }\n }\n }\n\n /**\n * Iterates over the segments of a serialized path.\n *\n * @example\n *\n * `LookupByPath.iteratePathSegments('foo/bar/baz')` yields 'foo', 'bar', 'baz'\n *\n * `LookupByPath.iteratePathSegments('foo\\\\bar\\\\baz', '\\\\')` yields 'foo', 'bar', 'baz'\n */\n public static *iteratePathSegments(serializedPath: string, delimiter: string = '/'): Iterable<string> {\n for (const prefixMatch of this._iteratePrefixes(serializedPath, delimiter)) {\n yield prefixMatch.prefix;\n }\n }\n\n private static *_iteratePrefixes(input: string, delimiter: string = '/'): Iterable<IPrefixEntry> {\n if (!input) {\n return;\n }\n\n let previousIndex: number = 0;\n let nextIndex: number = input.indexOf(delimiter);\n\n // Leading segments\n while (nextIndex >= 0) {\n yield {\n prefix: input.slice(previousIndex, nextIndex),\n index: nextIndex\n };\n previousIndex = nextIndex + 1;\n nextIndex = input.indexOf(delimiter, previousIndex);\n }\n\n // Last segment\n if (previousIndex < input.length) {\n yield {\n prefix: input.slice(previousIndex, input.length),\n index: input.length\n };\n }\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath.size}\n */\n public get size(): number {\n return this._size;\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath.tree}\n */\n public get tree(): IReadonlyPathTrieNode<TItem> {\n return this._root;\n }\n\n /**\n * Deletes all entries from this `LookupByPath` instance.\n *\n * @returns this, for chained calls\n */\n public clear(): this {\n this._root.value = undefined;\n this._root.children = undefined;\n this._size = 0;\n return this;\n }\n\n /**\n * Associates the value with the specified serialized path.\n * If a value is already associated, will overwrite.\n *\n * @returns this, for chained calls\n */\n public setItem(serializedPath: string, value: TItem, delimiter: string = this.delimiter): this {\n return this.setItemFromSegments(LookupByPath.iteratePathSegments(serializedPath, delimiter), value);\n }\n\n /**\n * Deletes an item if it exists.\n * @param query - The path to the item to delete\n * @param delimeter - Optional override delimeter for parsing the query\n * @returns `true` if the item was found and deleted, `false` otherwise\n * @remarks\n * If the node has children with values, they will be retained.\n */\n public deleteItem(query: string, delimeter: string = this.delimiter): boolean {\n const node: IPathTrieNode<TItem> | undefined = this._findNodeAtPrefix(query, delimeter);\n if (node?.value !== undefined) {\n node.value = undefined;\n this._size--;\n return true;\n }\n\n return false;\n }\n\n /**\n * Deletes an item and all its children.\n * @param query - The path to the item to delete\n * @param delimeter - Optional override delimeter for parsing the query\n * @returns `true` if any nodes were deleted, `false` otherwise\n */\n public deleteSubtree(query: string, delimeter: string = this.delimiter): boolean {\n const queryNode: IPathTrieNode<TItem> | undefined = this._findNodeAtPrefix(query, delimeter);\n if (!queryNode) {\n return false;\n }\n\n const queue: IPathTrieNode<TItem>[] = [queryNode];\n let removed: number = 0;\n while (queue.length > 0) {\n const node: IPathTrieNode<TItem> = queue.pop()!;\n if (node.value !== undefined) {\n node.value = undefined;\n removed++;\n }\n if (node.children) {\n for (const child of node.children.values()) {\n queue.push(child);\n }\n node.children.clear();\n }\n }\n\n this._size -= removed;\n return removed > 0;\n }\n\n /**\n * Associates the value with the specified path.\n * If a value is already associated, will overwrite.\n *\n * @returns this, for chained calls\n */\n public setItemFromSegments(pathSegments: Iterable<string>, value: TItem): this {\n let node: IPathTrieNode<TItem> = this._root;\n for (const segment of pathSegments) {\n if (!node.children) {\n node.children = new Map();\n }\n let child: IPathTrieNode<TItem> | undefined = node.children.get(segment);\n if (!child) {\n node.children.set(\n segment,\n (child = {\n value: undefined,\n children: undefined\n })\n );\n }\n node = child;\n }\n if (node.value === undefined) {\n this._size++;\n }\n node.value = value;\n\n return this;\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public findChildPath(childPath: string, delimiter: string = this.delimiter): TItem | undefined {\n return this.findChildPathFromSegments(LookupByPath.iteratePathSegments(childPath, delimiter));\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public findLongestPrefixMatch(\n query: string,\n delimiter: string = this.delimiter\n ): IPrefixMatch<TItem> | undefined {\n return this._findLongestPrefixMatch(LookupByPath._iteratePrefixes(query, delimiter));\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public findChildPathFromSegments(childPathSegments: Iterable<string>): TItem | undefined {\n let node: IPathTrieNode<TItem> = this._root;\n let best: TItem | undefined = node.value;\n // Trivial cases\n if (node.children) {\n for (const segment of childPathSegments) {\n const child: IPathTrieNode<TItem> | undefined = node.children.get(segment);\n if (!child) {\n break;\n }\n node = child;\n best = node.value ?? best;\n if (!node.children) {\n break;\n }\n }\n }\n\n return best;\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public has(key: string, delimiter: string = this.delimiter): boolean {\n const match: IPrefixMatch<TItem> | undefined = this.findLongestPrefixMatch(key, delimiter);\n return match?.index === key.length;\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public get(key: string, delimiter: string = this.delimiter): TItem | undefined {\n const match: IPrefixMatch<TItem> | undefined = this.findLongestPrefixMatch(key, delimiter);\n return match?.index === key.length ? match.value : undefined;\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public groupByChild<TInfo>(\n infoByPath: Map<string, TInfo>,\n delimiter: string = this.delimiter\n ): Map<TItem, Map<string, TInfo>> {\n const groupedInfoByChild: Map<TItem, Map<string, TInfo>> = new Map();\n\n for (const [path, info] of infoByPath) {\n const child: TItem | undefined = this.findChildPath(path, delimiter);\n if (child === undefined) {\n continue;\n }\n let groupedInfo: Map<string, TInfo> | undefined = groupedInfoByChild.get(child);\n if (!groupedInfo) {\n groupedInfo = new Map();\n groupedInfoByChild.set(child, groupedInfo);\n }\n groupedInfo.set(path, info);\n }\n\n return groupedInfoByChild;\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public *entries(query?: string, delimiter: string = this.delimiter): IterableIterator<[string, TItem]> {\n let root: IPathTrieNode<TItem> | undefined;\n if (query) {\n root = this._findNodeAtPrefix(query, delimiter);\n if (!root) {\n return;\n }\n } else {\n root = this._root;\n }\n\n const stack: [string, IPathTrieNode<TItem>][] = [[query ?? '', root]];\n while (stack.length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const [prefix, node] = stack.pop()!;\n if (node.value !== undefined) {\n yield [prefix, node.value];\n }\n if (node.children) {\n for (const [segment, child] of node.children) {\n stack.push([prefix ? `${prefix}${delimiter}${segment}` : segment, child]);\n }\n }\n }\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public [Symbol.iterator](\n query?: string,\n delimiter: string = this.delimiter\n ): IterableIterator<[string, TItem]> {\n return this.entries(query, delimiter);\n }\n\n /**\n * Iterates through progressively longer prefixes of a given string and returns as soon\n * as the number of candidate items that match the prefix are 1 or 0.\n *\n * If a match is present, returns the matched itme and the length of the matched prefix.\n *\n * @returns the found item, or `undefined` if no item was found\n */\n private _findLongestPrefixMatch(prefixes: Iterable<IPrefixEntry>): IPrefixMatch<TItem> | undefined {\n let node: IPathTrieNode<TItem> = this._root;\n let best: IPrefixMatch<TItem> | undefined = node.value\n ? {\n value: node.value,\n index: 0,\n lastMatch: undefined\n }\n : undefined;\n // Trivial cases\n if (node.children) {\n for (const { prefix: hash, index } of prefixes) {\n const child: IPathTrieNode<TItem> | undefined = node.children.get(hash);\n if (!child) {\n break;\n }\n node = child;\n if (node.value !== undefined) {\n best = {\n value: node.value,\n index,\n lastMatch: best\n };\n }\n if (!node.children) {\n break;\n }\n }\n }\n\n return best;\n }\n\n /**\n * Finds the node at the specified path, or `undefined` if no node was found.\n *\n * @param query - The path to the node to search for\n * @returns The trie node at the specified path, or `undefined` if no node was found\n */\n private _findNodeAtPrefix(\n query: string,\n delimiter: string = this.delimiter\n ): IPathTrieNode<TItem> | undefined {\n let node: IPathTrieNode<TItem> = this._root;\n for (const { prefix } of LookupByPath._iteratePrefixes(query, delimiter)) {\n if (!node.children) {\n return undefined;\n }\n const child: IPathTrieNode<TItem> | undefined = node.children.get(prefix);\n if (!child) {\n return undefined;\n }\n node = child;\n }\n return node;\n }\n}\n"]}
1
+ {"version":3,"file":"LookupByPath.js","sourceRoot":"","sources":["../src/LookupByPath.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AA6L3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,YAAY;IAgBvB;;;;OAIG;IACH,YAAmB,OAAmC,EAAE,SAAkB;QACxE,IAAI,CAAC,KAAK,GAAG;YACX,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE,SAAS;SACpB,CAAC;QAEF,IAAI,CAAC,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,GAAG,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAEf,IAAI,OAAO,EAAE,CAAC;YACZ,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC;gBACnC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,CAAC,mBAAmB,CAAC,cAAsB,EAAE,YAAoB,GAAG;QAChF,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,SAAS,CAAC,EAAE,CAAC;YAC3E,MAAM,WAAW,CAAC,MAAM,CAAC;QAC3B,CA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AI,GAAG,KAAK,CAAC;gBACb,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;oBAC7B,IAAI,GAAG;wBACL,KAAK,EAAE,IAAI,CAAC,KAAK;wBACjB,KAAK;wBACL,SAAS,EAAE,IAAI;qBAChB,CAAC;gBACJ,CAAC;gBACD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACnB,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CACvB,KAAa,EACb,YAAoB,IAAI,CAAC,SAAS;QAElC,IAAI,IAAI,GAAyB,IAAI,CAAC,KAAK,CAAC;QAC5C,KAAK,MAAM,EAAE,MAAM,EAAE,IAAI,YAAY,CAAC,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;YACzE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnB,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,MAAM,KAAK,GAAqC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC1E,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,IAAI,GAAG,KAAK,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA9XD,oCA8XC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * A node in the path trie used in LookupByPath\n */\ninterface IPathTrieNode<TItem extends {}> {\n /**\n * The value that exactly matches the current relative path\n */\n value: TItem | undefined;\n\n /**\n * Child nodes by subfolder\n */\n children: Map<string, IPathTrieNode<TItem>> | undefined;\n}\n\n/**\n * Readonly view of a node in the path trie used in LookupByPath\n *\n * @remarks\n * This interface is used to facilitate parallel traversals for comparing two `LookupByPath` instances.\n *\n * @beta\n */\nexport interface IReadonlyPathTrieNode<TItem extends {}> {\n /**\n * The value that exactly matches the current relative path\n */\n readonly value: TItem | undefined;\n\n /**\n * Child nodes by subfolder\n */\n readonly children: ReadonlyMap<string, IReadonlyPathTrieNode<TItem>> | undefined;\n}\n\ninterface IPrefixEntry {\n /**\n * The prefix that was matched\n */\n prefix: string;\n\n /**\n * The index of the first character after the matched prefix\n */\n index: number;\n}\n\n/**\n * Object containing both the matched item and the start index of the remainder of the query.\n *\n * @beta\n */\nexport interface IPrefixMatch<TItem extends {}> {\n /**\n * The item that matched the prefix\n */\n value: TItem;\n\n /**\n * The index of the first character after the matched prefix\n */\n index: number;\n\n /**\n * The last match found (with a shorter prefix), if any\n */\n lastMatch?: IPrefixMatch<TItem>;\n}\n\n/**\n * The readonly component of `LookupByPath`, to simplify unit testing.\n *\n * @beta\n */\nexport interface IReadonlyLookupByPath<TItem extends {}> extends Iterable<[string, TItem]> {\n /**\n * Searches for the item associated with `childPath`, or the nearest ancestor of that path that\n * has an associated item.\n *\n * @returns the found item, or `undefined` if no item was found\n *\n * @example\n * ```ts\n * const trie = new LookupByPath([['foo', 1], ['foo/bar', 2]]);\n * trie.findChildPath('foo/baz'); // returns 1\n * trie.findChildPath('foo/bar/baz'); // returns 2\n * ```\n */\n findChildPath(childPath: string, delimiter?: string): TItem | undefined;\n\n /**\n * Searches for the item for which the recorded prefix is the longest matching prefix of `query`.\n * Obtains both the item and the length of the matched prefix, so that the remainder of the path can be\n * extracted.\n *\n * @returns the found item and the length of the matched prefix, or `undefined` if no item was found\n *\n * @example\n * ```ts\n * const trie = new LookupByPath([['foo', 1], ['foo/bar', 2]]);\n * trie.findLongestPrefixMatch('foo/baz'); // returns { item: 1, index: 3 }\n * trie.findLongestPrefixMatch('foo/bar/baz'); // returns { item: 2, index: 7 }\n * ```\n */\n findLongestPrefixMatch(query: string, delimiter?: string): IPrefixMatch<TItem> | undefined;\n\n /**\n * Searches for the item associated with `childPathSegments`, or the nearest ancestor of that path that\n * has an associated item.\n *\n * @returns the found item, or `undefined` if no item was found\n *\n * @example\n * ```ts\n * const trie = new LookupByPath([['foo', 1], ['foo/bar', 2]]);\n * trie.findChildPathFromSegments(['foo', 'baz']); // returns 1\n * trie.findChildPathFromSegments(['foo','bar', 'baz']); // returns 2\n * ```\n */\n findChildPathFromSegments(childPathSegments: Iterable<string>): TItem | undefined;\n\n /**\n * Determines if an entry exists exactly at the specified path.\n *\n * @returns `true` if an entry exists at the specified path, `false` otherwise\n */\n has(query: string, delimiter?: string): boolean;\n\n /**\n * Retrieves the entry that exists exactly at the specified path, if any.\n *\n * @returns The entry that exists exactly at the specified path, or `undefined` if no entry exists.\n */\n get(query: string, delimiter?: string): TItem | undefined;\n\n /**\n * Gets the number of entries in this trie.\n *\n * @returns The number of entries in this trie.\n */\n get size(): number;\n\n /**\n * @returns The root node of the trie, corresponding to the path ''\n */\n get tree(): IReadonlyPathTrieNode<TItem>;\n\n /**\n * Iterates over the entries in this trie.\n *\n * @param query - An optional query. If specified only entries that start with the query will be returned.\n *\n * @returns An iterator over the entries under the specified query (or the root if no query is specified).\n * @remarks\n * Keys in the returned iterator use the provided delimiter to join segments.\n * Iteration order is not specified.\n * @example\n * ```ts\n * const trie = new LookupByPath([['foo', 1], ['foo/bar', 2]]);\n * [...trie.entries(undefined, ',')); // returns [['foo', 1], ['foo,bar', 2]]\n * ```\n */\n entries(query?: string, delimiter?: string): IterableIterator<[string, TItem]>;\n\n /**\n * Iterates over the entries in this trie.\n *\n * @param query - An optional query. If specified only entries that start with the query will be returned.\n *\n * @returns An iterator over the entries under the specified query (or the root if no query is specified).\n * @remarks\n * Keys in the returned iterator use the provided delimiter to join segments.\n * Iteration order is not specified.\n */\n [Symbol.iterator](query?: string, delimiter?: string): IterableIterator<[string, TItem]>;\n\n /**\n * Groups the provided map of info by the nearest entry in the trie that contains the path. If the path\n * is not found in the trie, the info is ignored.\n *\n * @returns The grouped info, grouped by the nearest entry in the trie that contains the path\n *\n * @param infoByPath - The info to be grouped, keyed by path\n */\n groupByChild<TInfo>(infoByPath: Map<string, TInfo>, delimiter?: string): Map<TItem, Map<string, TInfo>>;\n}\n\n/**\n * This class is used to associate path-like-strings, such as those returned by `git` commands,\n * with entities that correspond with ancestor folders, such as Rush Projects or npm packages.\n *\n * It is optimized for efficiently locating the nearest ancestor path with an associated value.\n *\n * It is implemented as a Trie (https://en.wikipedia.org/wiki/Trie) data structure, with each edge\n * being a path segment.\n *\n * @example\n * ```ts\n * const trie = new LookupByPath([['foo', 1], ['bar', 2], ['foo/bar', 3]]);\n * trie.findChildPath('foo'); // returns 1\n * trie.findChildPath('foo/baz'); // returns 1\n * trie.findChildPath('baz'); // returns undefined\n * trie.findChildPath('foo/bar/baz'); returns 3\n * trie.findChildPath('bar/foo/bar'); returns 2\n * ```\n * @beta\n */\nexport class LookupByPath<TItem extends {}> implements IReadonlyLookupByPath<TItem> {\n /**\n * The delimiter used to split paths\n */\n public readonly delimiter: string;\n\n /**\n * The root node of the trie, corresponding to the path ''\n */\n private readonly _root: IPathTrieNode<TItem>;\n\n /**\n * The number of entries in this trie.\n */\n private _size: number;\n\n /**\n * Constructs a new `LookupByPath`\n *\n * @param entries - Initial path-value pairs to populate the trie.\n */\n public constructor(entries?: Iterable<[string, TItem]>, delimiter?: string) {\n this._root = {\n value: undefined,\n children: undefined\n };\n\n this.delimiter = delimiter ?? '/';\n this._size = 0;\n\n if (entries) {\n for (const [path, item] of entries) {\n this.setItem(path, item);\n }\n }\n }\n\n /**\n * Iterates over the segments of a serialized path.\n *\n * @example\n *\n * `LookupByPath.iteratePathSegments('foo/bar/baz')` yields 'foo', 'bar', 'baz'\n *\n * `LookupByPath.iteratePathSegments('foo\\\\bar\\\\baz', '\\\\')` yields 'foo', 'bar', 'baz'\n */\n public static *iteratePathSegments(serializedPath: string, delimiter: string = '/'): Iterable<string> {\n for (const prefixMatch of this._iteratePrefixes(serializedPath, delimiter)) {\n yield prefixMatch.prefix;\n }\n }\n\n private static *_iteratePrefixes(input: string, delimiter: string = '/'): Iterable<IPrefixEntry> {\n if (!input) {\n return;\n }\n\n let previousIndex: number = 0;\n let nextIndex: number = input.indexOf(delimiter);\n\n // Leading segments\n while (nextIndex >= 0) {\n yield {\n prefix: input.slice(previousIndex, nextIndex),\n index: nextIndex\n };\n previousIndex = nextIndex + 1;\n nextIndex = input.indexOf(delimiter, previousIndex);\n }\n\n // Last segment\n if (previousIndex < input.length) {\n yield {\n prefix: input.slice(previousIndex, input.length),\n index: input.length\n };\n }\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath.size}\n */\n public get size(): number {\n return this._size;\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath.tree}\n */\n public get tree(): IReadonlyPathTrieNode<TItem> {\n return this._root;\n }\n\n /**\n * Deletes all entries from this `LookupByPath` instance.\n *\n * @returns this, for chained calls\n */\n public clear(): this {\n this._root.value = undefined;\n this._root.children = undefined;\n this._size = 0;\n return this;\n }\n\n /**\n * Associates the value with the specified serialized path.\n * If a value is already associated, will overwrite.\n *\n * @returns this, for chained calls\n */\n public setItem(serializedPath: string, value: TItem, delimiter: string = this.delimiter): this {\n return this.setItemFromSegments(LookupByPath.iteratePathSegments(serializedPath, delimiter), value);\n }\n\n /**\n * Deletes an item if it exists.\n * @param query - The path to the item to delete\n * @param delimeter - Optional override delimeter for parsing the query\n * @returns `true` if the item was found and deleted, `false` otherwise\n * @remarks\n * If the node has children with values, they will be retained.\n */\n public deleteItem(query: string, delimeter: string = this.delimiter): boolean {\n const node: IPathTrieNode<TItem> | undefined = this._findNodeAtPrefix(query, delimeter);\n if (node?.value !== undefined) {\n node.value = undefined;\n this._size--;\n return true;\n }\n\n return false;\n }\n\n /**\n * Deletes an item and all its children.\n * @param query - The path to the item to delete\n * @param delimeter - Optional override delimeter for parsing the query\n * @returns `true` if any nodes were deleted, `false` otherwise\n */\n public deleteSubtree(query: string, delimeter: string = this.delimiter): boolean {\n const queryNode: IPathTrieNode<TItem> | undefined = this._findNodeAtPrefix(query, delimeter);\n if (!queryNode) {\n return false;\n }\n\n const queue: IPathTrieNode<TItem>[] = [queryNode];\n let removed: number = 0;\n while (queue.length > 0) {\n const node: IPathTrieNode<TItem> = queue.pop()!;\n if (node.value !== undefined) {\n node.value = undefined;\n removed++;\n }\n if (node.children) {\n for (const child of node.children.values()) {\n queue.push(child);\n }\n node.children.clear();\n }\n }\n\n this._size -= removed;\n return removed > 0;\n }\n\n /**\n * Associates the value with the specified path.\n * If a value is already associated, will overwrite.\n *\n * @returns this, for chained calls\n */\n public setItemFromSegments(pathSegments: Iterable<string>, value: TItem): this {\n let node: IPathTrieNode<TItem> = this._root;\n for (const segment of pathSegments) {\n if (!node.children) {\n node.children = new Map();\n }\n let child: IPathTrieNode<TItem> | undefined = node.children.get(segment);\n if (!child) {\n node.children.set(\n segment,\n (child = {\n value: undefined,\n children: undefined\n })\n );\n }\n node = child;\n }\n if (node.value === undefined) {\n this._size++;\n }\n node.value = value;\n\n return this;\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public findChildPath(childPath: string, delimiter: string = this.delimiter): TItem | undefined {\n return this.findChildPathFromSegments(LookupByPath.iteratePathSegments(childPath, delimiter));\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public findLongestPrefixMatch(\n query: string,\n delimiter: string = this.delimiter\n ): IPrefixMatch<TItem> | undefined {\n return this._findLongestPrefixMatch(LookupByPath._iteratePrefixes(query, delimiter));\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public findChildPathFromSegments(childPathSegments: Iterable<string>): TItem | undefined {\n let node: IPathTrieNode<TItem> = this._root;\n let best: TItem | undefined = node.value;\n // Trivial cases\n if (node.children) {\n for (const segment of childPathSegments) {\n const child: IPathTrieNode<TItem> | undefined = node.children.get(segment);\n if (!child) {\n break;\n }\n node = child;\n best = node.value ?? best;\n if (!node.children) {\n break;\n }\n }\n }\n\n return best;\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public has(key: string, delimiter: string = this.delimiter): boolean {\n const match: IPrefixMatch<TItem> | undefined = this.findLongestPrefixMatch(key, delimiter);\n return match?.index === key.length;\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public get(key: string, delimiter: string = this.delimiter): TItem | undefined {\n const match: IPrefixMatch<TItem> | undefined = this.findLongestPrefixMatch(key, delimiter);\n return match?.index === key.length ? match.value : undefined;\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public groupByChild<TInfo>(\n infoByPath: Map<string, TInfo>,\n delimiter: string = this.delimiter\n ): Map<TItem, Map<string, TInfo>> {\n const groupedInfoByChild: Map<TItem, Map<string, TInfo>> = new Map();\n\n for (const [path, info] of infoByPath) {\n const child: TItem | undefined = this.findChildPath(path, delimiter);\n if (child === undefined) {\n continue;\n }\n let groupedInfo: Map<string, TInfo> | undefined = groupedInfoByChild.get(child);\n if (!groupedInfo) {\n groupedInfo = new Map();\n groupedInfoByChild.set(child, groupedInfo);\n }\n groupedInfo.set(path, info);\n }\n\n return groupedInfoByChild;\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public *entries(query?: string, delimiter: string = this.delimiter): IterableIterator<[string, TItem]> {\n let root: IPathTrieNode<TItem> | undefined;\n if (query) {\n root = this._findNodeAtPrefix(query, delimiter);\n if (!root) {\n return;\n }\n } else {\n root = this._root;\n }\n\n const stack: [string, IPathTrieNode<TItem>][] = [[query ?? '', root]];\n while (stack.length > 0) {\n const [prefix, node] = stack.pop()!;\n if (node.value !== undefined) {\n yield [prefix, node.value];\n }\n if (node.children) {\n for (const [segment, child] of node.children) {\n stack.push([prefix ? `${prefix}${delimiter}${segment}` : segment, child]);\n }\n }\n }\n }\n\n /**\n * {@inheritdoc IReadonlyLookupByPath}\n */\n public [Symbol.iterator](\n query?: string,\n delimiter: string = this.delimiter\n ): IterableIterator<[string, TItem]> {\n return this.entries(query, delimiter);\n }\n\n /**\n * Iterates through progressively longer prefixes of a given string and returns as soon\n * as the number of candidate items that match the prefix are 1 or 0.\n *\n * If a match is present, returns the matched itme and the length of the matched prefix.\n *\n * @returns the found item, or `undefined` if no item was found\n */\n private _findLongestPrefixMatch(prefixes: Iterable<IPrefixEntry>): IPrefixMatch<TItem> | undefined {\n let node: IPathTrieNode<TItem> = this._root;\n let best: IPrefixMatch<TItem> | undefined = node.value\n ? {\n value: node.value,\n index: 0,\n lastMatch: undefined\n }\n : undefined;\n // Trivial cases\n if (node.children) {\n for (const { prefix: hash, index } of prefixes) {\n const child: IPathTrieNode<TItem> | undefined = node.children.get(hash);\n if (!child) {\n break;\n }\n node = child;\n if (node.value !== undefined) {\n best = {\n value: node.value,\n index,\n lastMatch: best\n };\n }\n if (!node.children) {\n break;\n }\n }\n }\n\n return best;\n }\n\n /**\n * Finds the node at the specified path, or `undefined` if no node was found.\n *\n * @param query - The path to the node to search for\n * @returns The trie node at the specified path, or `undefined` if no node was found\n */\n private _findNodeAtPrefix(\n query: string,\n delimiter: string = this.delimiter\n ): IPathTrieNode<TItem> | undefined {\n let node: IPathTrieNode<TItem> = this._root;\n for (const { prefix } of LookupByPath._iteratePrefixes(query, delimiter)) {\n if (!node.children) {\n return undefined;\n }\n const child: IPathTrieNode<TItem> | undefined = node.children.get(prefix);\n if (!child) {\n return undefined;\n }\n node = child;\n }\n return node;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/lookup-by-path",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "Strongly typed trie data structure for path and URL-like strings.",
5
5
  "main": "lib/index.js",
6
6
  "typings": "dist/lookup-by-path.d.ts",
@@ -18,7 +18,8 @@
18
18
  "directory": "libraries/lookup-by-path"
19
19
  },
20
20
  "devDependencies": {
21
- "@rushstack/heft": "0.74.0",
21
+ "eslint": "~9.25.1",
22
+ "@rushstack/heft": "0.74.2",
22
23
  "local-node-rig": "1.0.0"
23
24
  },
24
25
  "peerDependencies": {