Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x | export type Page<T> = { items: T[]; next?: string | null; prev?: string | null; total?: number | null }
type PageLike<T> = { items?: T[]; nextCursor?: string | null; prevCursor?: string | null; total?: number | null }
export function fromOpenApiPage<TIn, TOut>(page: PageLike<TIn> | null | undefined, mapItem: (i: TIn) => TOut): Page<TOut> {
if (!page) return { items: [] }
return {
items: (page.items ?? []).map((i) => mapItem(i)),
next: page.nextCursor ?? null,
prev: page.prevCursor ?? null,
total: page.total ?? null,
}
}
|