Constuctor doesn't work the same as a real DataView?
See original GitHub issueAFAICT a real DataView
requires an ArrayBuffer
in it’s constructor but a JDataView requires a Buffer
or Uint8Array
Trying this in the browser console
new DataView(new Uint8Array(3));
In Chrome I get Uncaught TypeError: First argument to DataView constructor must be an ArrayBuffer
and in Firefox I get TypeError: DataView: expected ArrayBuffer, got Uint8Array
.
If I use
new DataView(new Uint8Array(3).buffer);
Then it works in both.
Conversely with JDataView 2.5.0 the first one succeeds even though it shouldn’t according to the spec. The second one fails.
Is that what you want to happen?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Flaw: Constructor does Real Work - Stack Overflow
The class is responsible for holding a list containing all values between start and end value taking the stepSize into consideration.
Read more >constructor - JavaScript - MDN Web Docs - Mozilla
The constructor method is a special method of a class for creating and initializing an object instance of that class.
Read more >DataView Constructor (System.Data) - Microsoft Learn
Initializes a new instance of the DataView class with the specified DataTable, RowFilter, Sort, and DataViewRowState.
Read more >Google Visualization API Reference | Charts
This constructor creates a new DataView by assigning a serialized DataView to a DataTable . It helps you recreate the DataView that you...
Read more >20. Typed Arrays - Exploring JS
In order to create a DataView, you need to provide its constructor with an ArrayBuffer. Typed Array constructors can optionally create an ArrayBuffer...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s a generic JavaScript rule of thumb, nothing specific to this library to justify explaining these things.
However, if you want to improve feature detection to avoid this case, I’ll accept a PR.
maybe you should put that in big giant letters because others are unaware of the issues. I’m here because other multi module libraries are using jdataview this way and digging into them this is the reason they were failing.
They wrote the libraries to work with
DataView
and then dropped in your library to support those platforms that don’t haveDataView