JSPM

dataview2

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 57
  • Score
    100M100P100Q89639F
  • License MIT

Efficient DataView for isomorphic libraries

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

Build Status NPM Version License

Efficient DataView for isomorphic libraries

Installation

npm:

npm install dataview2

API

  • DataView2(buffer: Buffer|ArrayBuffer): BufferDataView|DataView
    • node.js: returns an instance of BufferDataView
    • browser: returns an instance of DataView
  • Buffer2(n: size): Buffer|ArrayBuufer
    • node.js: return an instance of Buffer
    • browser: return an instance of ArrayBuffer

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);
// → true

use 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.1234130859375

License

MIT