8000 fix: handle get on empty lists by fly1d · Pull Request #190 · rvagg/bl · GitHub
[go: up one dir, main page]

Skip to content

fix: handle get on empty lists - #190

Open
fly1d wants to merge 1 commit into
rvagg:masterfrom
fly1d:fix/empty-list-get
Open

fly1d wants to merge 1 commit into
rvagg:masterfrom
fly1d:fix/empty-list-get

Conversation

@fly1d
@fly1d fly1d commented Oct 30, 2026
Copy link
Copy Markdown

get(0) throws a TypeError on a new empty list or after consume() drains it. This affects both BufferList and BufferListStream, while an end index on a nonempty list already returns undefined.

Treat index === length as out of range before looking up an internal buffer. Add a separate Tape test for both classes, with boundary and append/reuse controls. The same final fixture executes all 12 new assertions on pristine code: four empty-list checks fail and eight controls pass; all 12 pass with the fix.

Validation on Node 26.5.0, macOS arm64: npm run build, full npm run test:ci (Standard, Tape, generated types and TypeScript checks), syntax checks and git diff --check pass. Generated tracked files remain unchanged. Other Node versions and operating systems were not run.

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

0