Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new BitView() fails with byteOffset specified #24

Open
chrisveness opened this issue Dec 10, 2020 · 0 comments
Open

new BitView() fails with byteOffset specified #24

chrisveness opened this issue Dec 10, 2020 · 0 comments

Comments

@chrisveness
Copy link

If the BitView constructor is invoked with (non-zero) byteOffset and no byteLength, it fails with Uncaught RangeError: Invalid typed array length error.

To replicate:

$ node
> BitView = require('bit-buffer').BitView;
> array = new ArrayBuffer(8);
> bv = new BitView(array, 4);
Uncaught RangeError: Invalid typed array length: 8
    at new Uint8Array (<anonymous>)
    at new BitView (.../node_modules/bit-buffer/bit-buffer.js:22:15)

I think the solution would be to change line 20 to

byteLength = byteLength || source.byteLength-byteOffset /* ArrayBuffer */ || source.length-byteOffset /* Buffer */;
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

No branches or pull requests

1 participant