Skip to content

fix(takeLast): handle Infinity count - #1

Draft
yowainwright wants to merge 1 commit into
masterfrom
fix/take-last-infinity-v9
Draft

fix(takeLast): handle Infinity count#1
yowainwright wants to merge 1 commit into
masterfrom
fix/take-last-infinity-v9

Conversation

@yowainwright

@yowainwright yowainwright commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Description

takeLast(Infinity) currently allocates new Array(Infinity), which throws RangeError: Invalid array length.

This 1 line update assigns a growable buffer only for Infinity, while preserving the existing finite-count ring buffer and non-positive early-complete behavior.

  • The regression test verifies that values are still emitted on completion.

Related issue (if exists)

@yowainwright

Copy link
Copy Markdown
Owner Author

@greptile

@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown

Greptile Summary

The PR fixes takeLast(Infinity) by selecting a growable array instead of attempting an invalid fixed-size allocation.

  • Preserves the existing finite-count ring buffer and non-positive-count behavior.
  • Adds a regression test confirming that all buffered values are emitted in order upon completion.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The growable Infinity buffer works with the existing modulo and completion traversal to retain and emit all observed values in order, while finite and non-positive paths remain unchanged.

Important Files Changed

Filename Overview
packages/rxjs/src/take-last.ts Correctly special-cases Infinity during buffer allocation while retaining the existing indexing and completion logic.
packages/rxjs/src/take-last.spec.ts Adds focused coverage showing that the Infinity path buffers values without errors and emits them before completion.

Reviews (1): Last reviewed commit: "fix(takeLast): handle Infinity count" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant