mirror of
https://github.com/beilunyang/moemail.git
synced 2025-09-27 03:46:03 +08:00
14 lines
396 B
TypeScript
14 lines
396 B
TypeScript
interface CursorData {
|
|
timestamp: number
|
|
id: string
|
|
}
|
|
|
|
export function encodeCursor(timestamp: number, id: string): string {
|
|
const data: CursorData = { timestamp, id }
|
|
return Buffer.from(JSON.stringify(data)).toString('base64')
|
|
}
|
|
|
|
export function decodeCursor(cursor: string): CursorData {
|
|
const data = JSON.parse(Buffer.from(cursor, 'base64').toString())
|
|
return data as CursorData
|
|
}
|