MCPcopy
hub / github.com/jonaskello/tsconfig-paths / sortByLongestPrefix

Function sortByLongestPrefix

src/mapping-entry.ts:56–60  ·  view source on GitHub ↗

* Sort path patterns. * If a module name can be matched with multiple patterns then pattern with the longest prefix will be picked.

(arr: Array<string>)

Source from the content-addressed store, hash-verified

54 * If a module name can be matched with multiple patterns then pattern with the longest prefix will be picked.
55 */
56function sortByLongestPrefix(arr: Array<string>): Array<string> {
57 return arr
58 .concat()
59 .sort((a: string, b: string) => getPrefixLength(b) - getPrefixLength(a));
60}
61
62function getPrefixLength(pattern: string): number {
63 const prefixLength = pattern.indexOf("*");

Callers 1

Calls 1

getPrefixLengthFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…