@tanstack/router-generator
Advanced tools
Comparing version 1.54.0 to 1.55.0
import { RouteNode } from './types.js'; | ||
import { Config } from './config.js'; | ||
export declare function generator(config: Config): Promise<void>; | ||
export declare function multiSortBy<T>(arr: Array<T>, accessors?: Array<(item: T) => any>): Array<T>; | ||
/** | ||
@@ -6,0 +5,0 @@ * Removes the last segment from a given path. Segments are considered to be separated by a '/'. |
@@ -5,3 +5,3 @@ import path from "node:path"; | ||
import * as prettier from "prettier"; | ||
import { logging, replaceBackslash, removeExt, removeUnderscores, removeTrailingSlash, determineInitialRoutePath, trimPathLeft, routePathToVariable } from "./utils.js"; | ||
import { logging, multiSortBy, replaceBackslash, removeExt, removeUnderscores, removeTrailingSlash, determineInitialRoutePath, trimPathLeft, routePathToVariable } from "./utils.js"; | ||
import { getRouteNodes as getRouteNodes$1 } from "./filesystem/physical/getRouteNodes.js"; | ||
@@ -493,21 +493,2 @@ import { getRouteNodes } from "./filesystem/virtual/getRouteNodes.js"; | ||
} | ||
function multiSortBy(arr, accessors = [(d) => d]) { | ||
return arr.map((d, i) => [d, i]).sort(([a, ai], [b, bi]) => { | ||
for (const accessor of accessors) { | ||
const ao = accessor(a); | ||
const bo = accessor(b); | ||
if (typeof ao === "undefined") { | ||
if (typeof bo === "undefined") { | ||
continue; | ||
} | ||
return 1; | ||
} | ||
if (ao === bo) { | ||
continue; | ||
} | ||
return ao > bo ? 1 : -1; | ||
} | ||
return ai - bi; | ||
}).map(([d]) => d); | ||
} | ||
function removeTrailingUnderscores(s) { | ||
@@ -611,3 +592,2 @@ return s == null ? void 0 : s.replaceAll(/(_$)/gi, "").replaceAll(/(_\/)/gi, "/"); | ||
inferPath, | ||
multiSortBy, | ||
removeLastSegmentFromPath, | ||
@@ -614,0 +594,0 @@ startAPIRouteSegmentsFromTSRFilePath |
@@ -0,1 +1,2 @@ | ||
export declare function multiSortBy<T>(arr: Array<T>, accessors?: Array<(item: T) => any>): Array<T>; | ||
export declare function cleanPath(path: string): string; | ||
@@ -2,0 +3,0 @@ export declare function trimPathLeft(path: string): string; |
@@ -0,1 +1,20 @@ | ||
function multiSortBy(arr, accessors = [(d) => d]) { | ||
return arr.map((d, i) => [d, i]).sort(([a, ai], [b, bi]) => { | ||
for (const accessor of accessors) { | ||
const ao = accessor(a); | ||
const bo = accessor(b); | ||
if (typeof ao === "undefined") { | ||
if (typeof bo === "undefined") { | ||
continue; | ||
} | ||
return 1; | ||
} | ||
if (ao === bo) { | ||
continue; | ||
} | ||
return ao > bo ? 1 : -1; | ||
} | ||
return ai - bi; | ||
}).map(([d]) => d); | ||
} | ||
function cleanPath(path) { | ||
@@ -57,2 +76,3 @@ return path.replace(/\/{2,}/g, "/"); | ||
logging, | ||
multiSortBy, | ||
removeExt, | ||
@@ -59,0 +79,0 @@ removeLeadingSlash, |
{ | ||
"name": "@tanstack/router-generator", | ||
"version": "1.54.0", | ||
"version": "1.55.0", | ||
"description": "Modern and scalable routing for React applications", | ||
@@ -5,0 +5,0 @@ "author": "Tanner Linsley", |
@@ -8,2 +8,3 @@ import path from 'node:path' | ||
logging, | ||
multiSortBy, | ||
removeExt, | ||
@@ -675,32 +676,2 @@ removeTrailingSlash, | ||
export function multiSortBy<T>( | ||
arr: Array<T>, | ||
accessors: Array<(item: T) => any> = [(d) => d], | ||
): Array<T> { | ||
return arr | ||
.map((d, i) => [d, i] as const) | ||
.sort(([a, ai], [b, bi]) => { | ||
for (const accessor of accessors) { | ||
const ao = accessor(a) | ||
const bo = accessor(b) | ||
if (typeof ao === 'undefined') { | ||
if (typeof bo === 'undefined') { | ||
continue | ||
} | ||
return 1 | ||
} | ||
if (ao === bo) { | ||
continue | ||
} | ||
return ao > bo ? 1 : -1 | ||
} | ||
return ai - bi | ||
}) | ||
.map(([d]) => d) | ||
} | ||
function removeTrailingUnderscores(s?: string) { | ||
@@ -707,0 +678,0 @@ return s?.replaceAll(/(_$)/gi, '').replaceAll(/(_\/)/gi, '/') |
@@ -0,1 +1,31 @@ | ||
export function multiSortBy<T>( | ||
arr: Array<T>, | ||
accessors: Array<(item: T) => any> = [(d) => d], | ||
): Array<T> { | ||
return arr | ||
.map((d, i) => [d, i] as const) | ||
.sort(([a, ai], [b, bi]) => { | ||
for (const accessor of accessors) { | ||
const ao = accessor(a) | ||
const bo = accessor(b) | ||
if (typeof ao === 'undefined') { | ||
if (typeof bo === 'undefined') { | ||
continue | ||
} | ||
return 1 | ||
} | ||
if (ao === bo) { | ||
continue | ||
} | ||
return ao > bo ? 1 : -1 | ||
} | ||
return ai - bi | ||
}) | ||
.map(([d]) => d) | ||
} | ||
export function cleanPath(path: string) { | ||
@@ -2,0 +32,0 @@ // remove double slashes |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
274142
3588