Skip to content

fix: range creates array with only one element when end is 0#463

Open
Richard-Krug wants to merge 1 commit into
sodiray:masterfrom
Richard-Krug:fix-range-for-end-zero
Open

fix: range creates array with only one element when end is 0#463
Richard-Krug wants to merge 1 commit into
sodiray:masterfrom
Richard-Krug:fix-range-for-end-zero

Conversation

@Richard-Krug

@Richard-Krug Richard-Krug commented Aug 20, 2025

Copy link
Copy Markdown

Description

  • Fix bug where range creates an array with only one element when end is 0
    • e.g. range(-3, 0) returned [0] instead of [-3, -2, -1, 0]
  • Problem: Because 0 is falsy the start was overwritten with 0 when end is 0 resulting in the array [0]
  • Solution: Explicitly check for end !== undefined to prevent this
  • Add test case where end is 0

Checklist

  • Changes are covered by tests if behavior has been changed or added
  • Tests have 100% coverage
  • If code changes were made, the version in package.json has been bumped (matching semver)
  • If code changes were made, the yarn build command has been run and to update the cdn directory
  • If code changes were made, the documentation (in the /docs directory) has been updated

@vercel

vercel Bot commented Aug 20, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
radash-docs Ready Ready Preview Comment Aug 20, 2025 1:26pm

- because 0 is falsy the start was overwritten with 0 when end is 0 resulting in the array [0]
- explicitly check for end !== undefined to prevent this
- add test case where end is 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant