Reference · Collections and piles: pure helpers
movePagefunction
The first card of the page that is delta pages away, wrapping round at either end.
Import it
import { movePage } from "@johnmorrisdotca/fuda-cards/collection";
Definition
function movePage(index: number, length: number, pageSize: number, delta: number): number
Parameters
| Name | Type | Description |
|---|---|---|
index | number | The index of any card on the page now. |
length | number | How many cards the collection holds. |
pageSize | number | How many cards a page holds. |
delta | number | How many pages to move: 1 forward, -1 back. |
Returns
number
The index of the first card of that page; 0 for an empty collection.
Examples
import { movePage } from "@johnmorrisdotca/fuda-cards/collection";
console.log(movePage(6, 7, 3, 1), movePage(0, 7, 3, -1)); // 0 60 6What it prints (run when this page was built)