Skip to content

Commit 8565274

Browse files
fix: remove redundant condition in paginate guard clauses
When limit === undefined, limit !== 0 is always true — the && check was dead code. Simplified to just check limit === undefined. Impact: 2 functions changed, 18 affected
1 parent f593c36 commit 8565274

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/paginate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const MCP_MAX_LIMIT = 1000;
2828
* @returns {{ items: any[], pagination?: { total: number, offset: number, limit: number, hasMore: boolean, returned: number } }}
2929
*/
3030
export function paginate(items, { limit, offset } = {}) {
31-
if (limit === undefined && limit !== 0) {
31+
if (limit === undefined) {
3232
return { items };
3333
}
3434
const total = items.length;
@@ -59,7 +59,7 @@ export function paginate(items, { limit, offset } = {}) {
5959
* @returns {object} - Result with paginated field + `_pagination` (if active)
6060
*/
6161
export function paginateResult(result, field, { limit, offset } = {}) {
62-
if (limit === undefined && limit !== 0) {
62+
if (limit === undefined) {
6363
return result;
6464
}
6565
const arr = result[field];

0 commit comments

Comments
 (0)