You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Zade Viggers edited this page May 23, 2024
·
4 revisions
Note
This page has been updated for jDataView 3
First, we need a buffer, like so
// jDataView.from(...args) is a helper method that constructs a new jDataView instance// with the provided spread arguments. It only works in little-endian.letview=jDataView.from(0x00,0x00,0x01,0x10,// Int32 - 2720x47,0x1b,0xcf,0x90,// Float32 - 39887.56250,0,0,0,0,0,0,0,// 8 blank bytes0x4d,0x44,0x32,0x30,// String - MD200x61// Char - a);
Now, we use the DataView as defined in the specification. The only change is the "j" in front of "DataView."
The wrapper extends the specification to make the DataView easier to use.
// Create a new jDataView instance on the same bufferview=view.slice(0);// A position counter is managed. Remove the argument to read right after the last read.version=view.getInt32();// 272float=view.getFloat32();// 39887.5625// You can move around with tell(), seek() and skip()view.skip(8);// Helpers like getChar and getString will make your life easierconsttag=view.getString(4);// MD20constchar=view.getChar();// a