No cleaner development history than this exists. It's difficult to methodically design something when you don't yet know what it is you're designing.
14 lines
330 B
TypeScript
14 lines
330 B
TypeScript
// Make the names explicit so that we don't get the order mixed up
|
|
interface Params {
|
|
maxCount: number;
|
|
nextIndex: number;
|
|
}
|
|
|
|
export function paginationCookie<T>(items: T[], params: Params) {
|
|
if (items.length < params.maxCount) {
|
|
return "-1";
|
|
} else {
|
|
return (params.nextIndex + params.maxCount).toString();
|
|
}
|
|
}
|