diff --git a/spec/operators/every-spec.ts b/spec/operators/every-spec.ts index ee357ddefa..35ce7ae568 100644 --- a/spec/operators/every-spec.ts +++ b/spec/operators/every-spec.ts @@ -32,6 +32,18 @@ describe('every operator', () => { }); + it('should increment index on each call to the predicate', () => { + const indices: number[] = []; + of(1, 2, 3, 4).pipe( + every((_, i) => { + indices.push(i); + return true; + }) + ).subscribe(); + + expect(indices).to.deep.equal([0, 1, 2, 3]); + }); + it('should accept thisArg with array observables', () => { const thisArg = {}; diff --git a/src/internal/operators/every.ts b/src/internal/operators/every.ts index a1e7dd3bc1..20eba5b962 100644 --- a/src/internal/operators/every.ts +++ b/src/internal/operators/every.ts @@ -39,7 +39,7 @@ export function every( new OperatorSubscriber( subscriber, (value) => { - if (!predicate.call(thisArg, value, index, source)) { + if (!predicate.call(thisArg, value, index++, source)) { subscriber.next(false); subscriber.complete(); }