Utility for creating DataViews
lol
Installation requires npm
From the command line:
npm install data-view-builder
var builder = new DataViewBuilder();
builder.uint8(123);
Likewise for the other methods: uint16
, uint32
, int8
, int16
, int32
, float32
, float64
.
Each method returns the builder instance to allow for chaining.
builder.build();
Returns a DataView of an ArrayBuffer containing the values added between the last call to build
and now.
var builder = new DataViewBuilder();
builder.uint8(11).uint8(22);
var view = builder.build(); // [0xb, 0x16]
var builder = new DataViewBuilder();
builder.float32(13.37).int32(9001);
var view = builder.build(); // [ 0x41, 0x55, 0xeb, 0x85, 0x0, 0x0, 0x23, 0x29 ]
var builder = new DataViewBuilder();
builder.int8(1).int8(2);
var view1 = builder.build(); // [ 0x01, 0x02 ]
var view2 = builder.build(); // [] Empty!