JSPM

@hugov/byte-views

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q18943F
  • License MIT

ArrayBuffer partitions

Package Exports

  • @hugov/byte-views
  • @hugov/byte-views/byte-views.js

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 (@hugov/byte-views) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

byte-views

partition an ArrayBuffer into multiple DataViews and/or TypedArrays

import next from '@hugov/byte-views'
const memory = new ArrayBuffer(16),
      first = next(memory, Uint8Array, 4),  //using first 4 bytes
      second = next(first, Uint16Array, 2), //using next 4 bytes
      last = next(second)                   //Uint16Array on the remaining 8 bytes

Limitations

  • no protection against accidental memory overlaps if the buffer or reference is reused

License

MIT © Hugo Villeneuve