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

Function nearestWithPath

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

Source from the content-addressed store, hash-verified

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

Callers 1

recordShellRouteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected