Package Exports
- dataview2
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dataview2) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
dataview2
Efficient DataView for isomorphic libraries
Installation
npm:
npm install dataview2API
DataView2(buffer: Buffer|ArrayBuffer): BufferDataView|DataView- node.js: returns an instance of
BufferDataView - browser: returns an instance of
DataView
- node.js: returns an instance of
Buffer2(n: size): Buffer|ArrayBuufer- node.js: return an instance of
Buffer - browser: return an instance of
ArrayBuffer
- node.js: return an instance of
Examples
use Buffer in the Node.js
var buffer = new Buffer2(4); // → Buffer
var view = new DataView2(buffer); // → BufferDataView
// set a "float" in the data view
view.setFloat32(0, 1337.1234, true);
// ensure that the original Buffer was modified
console.log(buffer.readFloatLE(0));
// → 1337.1234130859375
console.log(view.buffer instanceof Buffer);
// → trueuse ArrayBuffer in the browser
var buffer new Buffer2(4); // → ArrayBuffer
var view = new DataView2(buffer); // → DataView
// set a "float" in the data view
view.setFloat32(0, 1337.1234, true);
console.log(view.buffer instanceof ArrayBuffer);
// → true
// ensure that the original ArrayBuffer was modified
console.log(new Float32Array(buffer)[0]);
// → 1337.1234130859375License
MIT