MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / decodeCursor

Function decodeCursor

apps/web/utilities/cursor.ts:16–34  ·  view source on GitHub ↗
(data?: string)

Source from the content-addressed store, hash-verified

14};
15
16export function decodeCursor(data?: string): FindThreadsByCursorType {
17 if (!data) return defaultCursor;
18 try {
19 const decoded = SKIP_ENCODE_CURSOR
20 ? data
21 : Buffer.from(data, 'base64').toString();
22 const split = decoded?.split(':');
23 if (split.length === 3) {
24 return {
25 sort: split[0] === 'asc' ? 'asc' : 'desc',
26 direction: split[1] as 'gt' | 'lt' | 'gte',
27 sentAt: split[2],
28 };
29 }
30 } catch (error) {
31 console.error(error);
32 }
33 return defaultCursor;
34}

Callers 5

cursor.test.tsFile · 0.90
topicGetServerSidePropsFunction · 0.90
getThreadsFunction · 0.90
channelNextPageFunction · 0.90
getThreadsFunction · 0.90

Calls 1

errorMethod · 0.65

Tested by

no test coverage detected