forked from Echo-Mirror-Butler/echomirror-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync.ts
More file actions
19 lines (16 loc) · 691 Bytes
/
Copy pathsync.ts
File metadata and controls
19 lines (16 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { assertReady, raw } from './load.js'
export interface SyncCursor {
ledgerSequence: number
pagingToken: string
totalProcessed: number
}
/** Serialize a sync cursor to a JSON string, for localStorage persistence in browsers. */
export function serializeCursor(cursor: SyncCursor): string {
assertReady('serializeCursor')
return raw.serialize_cursor(cursor.ledgerSequence, cursor.pagingToken, cursor.totalProcessed)
}
/** Parse a serialized cursor JSON string, returning its `pagingToken` field. */
export function parseCursorPagingToken(cursorJson: string): string | undefined {
assertReady('parseCursorPagingToken')
return raw.parse_cursor_paging_token(cursorJson)
}