We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9fa74c4 commit 2514929Copy full SHA for 2514929
1 file changed
src/text.ts
@@ -0,0 +1,25 @@
1
+export function normalizeNewlines(input: string): string {
2
+ return input.replace(/\r\n/g, '\n');
3
+}
4
+
5
+export function normalizePathSegments(segments: readonly string[]): string {
6
+ return segments
7
+ .map((segment, index) => {
8
+ if (segment === '[]') return segment;
9
+ return index > 0 ? `.${segment}` : segment;
10
+ })
11
+ .join('');
12
13
14
+export function extractPathName(canonicalPath: string): string {
15
+ return canonicalPath
16
+ .split(".")
17
+ .filter((part) => part.length > 0 && part !== "[]")
18
+ .at(-1) ?? "";
19
20
21
+export function sortedReadonly<T>(values: readonly T[], compare: (left: T, right: T) => number): readonly T[] {
22
+ const copy = [...values];
23
+ copy.sort(compare);
24
+ return copy;
25
0 commit comments