MCPcopy Create free account
hub / github.com/dailydotdev/apps / nearestWithPath

Function nearestWithPath

packages/shared/src/components/shell/shellNav.ts:213–225  ·  view source on GitHub ↗
(stack: RouteStack, path: string)

Source from the content-addressed store, hash-verified

211 !!globalThis?.document?.referrer && !isSameSiteReferrer();
212
213const nearestWithPath = (stack: RouteStack, path: string): number => {
214 for (let distance = 1; distance < stack.routes.length; distance += 1) {
215 const before = stack.pointer - distance;
216 if (stack.routes[before]?.path === path) {
217 return before;
218 }
219 const after = stack.pointer + distance;
220 if (stack.routes[after]?.path === path) {
221 return after;
222 }
223 }
224 return -1;
225};
226
227export const recordShellRoute = (
228 pathname: string,

Callers 1

recordShellRouteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected