Repository navigation
fix: calculate encoded lengths from view byte lengths - #214
Open
bensynapse wants to merge 1 commit into
Open
bensynapse wants to merge 1 commit into
bensynapse wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I run Live Tennis API.
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[X] Bug fix
[ ] New feature
[ ] Other, please explain:
What changes did you make? (Give an overview)
encodingLength()uses the view'sbyteLengthdirectly. A three byte view at offset 20 previously reported -13 encoded bytes. It now reports 5, matchingencode().The tests cover typed arrays, DataView and Buffer slices, including empty views and nested containers. A preallocation test reproduces the resulting
RangeErrorbefore the fix.Which issue (if any) does this pull request address?
No existing issue.
Is there anything you'd like reviewers to focus on?
A view's
byteLengthalready excludes bytes before its offset.node node_modules/tape/bin/tape test/encoding-length.test.jspasses all 39 assertions on Node 12.22.12 and 22.23.2. Standard passes on both versions.npm teststops indecode.dictionarywith aTextDecoderargument error on both versions. The same failure reproduces on unchanged master withuint8-util2.3.2.