Files
immich/server/src/utils/pagination.ts

17 lines
369 B
TypeScript
Raw Normal View History

2024-03-20 22:15:09 -05:00
export interface PaginationOptions {
take: number;
skip?: number;
}
export interface PaginationResult<T> {
items: T[];
hasNextPage: boolean;
}
2025-01-21 16:47:48 -05:00
export function paginationHelper<Entity extends object>(items: Entity[], take: number): PaginationResult<Entity> {
2024-03-20 22:15:09 -05:00
const hasNextPage = items.length > take;
items.splice(take);
return { items, hasNextPage };
}