fm code 'fix the page() bug in paginate.js: pages are 1-based but page 1 skips the first items' --worker claude
Plan FIX S · Fix 1-based page() offset in paginate.js
Steps
- Add a failing test in paginate.test.js asserting page([1, 2, 3, 4], 1, 2) deepEquals [1, 2]
- In paginate.js change the slice to use (n - 1) * size as the start offset: items.slice((n - 1) * size, n * size)
- Run npm test and confirm both the first-page and second-page tests pass
Checks
- PASS page(items, 1, size) returns the first `size` items
node -e "const {page}=require('./paginate');require('assert').deepStrictEqual(page([1,2,3,4],1,2),[1,2])"(failed before the work) - PASS page 2 returns the next items, and the full test suite passes
npm test(failed before the work)
Changed
paginate.test.js+4paginate.js+1 −1
Closed T-0001 closed; committed f8d6564 (2 files). Undo: git revert --no-edit f8d6564 (tokens: 66453 in, 645 out)