question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Constuctor doesn't work the same as a real DataView?

See original GitHub issue

AFAICT 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:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RReversercommented, Jul 27, 2017

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.

0reactions
greggmancommented, Jul 27, 2017

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 have DataView

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found