Skip to content

Commit 5804cb4

Browse files
committed
Allow first:0 last:0
1 parent 7ebb670 commit 5804cb4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/connection/__tests__/arrayconnection.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,20 +470,20 @@ describe('connectionFromArray()', () => {
470470
});
471471

472472
describe('cursor edge cases', () => {
473-
it('throws an error if first <= 0', () => {
473+
it('throws an error if first < 0', () => {
474474
expect(() => {
475475
connectionFromArray(
476476
letters,
477-
{first: 0}
477+
{first: -1}
478478
);
479479
}).to.throw('Argument "first" must be a non-negative integer');
480480
});
481481

482-
it('throws an error if last <= 0', () => {
482+
it('throws an error if last < 0', () => {
483483
expect(() => {
484484
connectionFromArray(
485485
letters,
486-
{last: 0}
486+
{last: -1}
487487
);
488488
}).to.throw('Argument "last" must be a non-negative integer');
489489
});

src/connection/arrayconnection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function connectionFromArraySlice<T>(
8585
arrayLength
8686
);
8787
if (typeof first === 'number') {
88-
if (first <= 0) {
88+
if (first < 0) {
8989
throw new Error('Argument "first" must be a non-negative integer');
9090
}
9191

@@ -95,7 +95,7 @@ export function connectionFromArraySlice<T>(
9595
);
9696
}
9797
if (typeof last === 'number') {
98-
if (last <= 0) {
98+
if (last < 0) {
9999
throw new Error('Argument "last" must be a non-negative integer');
100100
}
101101

0 commit comments

Comments
 (0)