0.1.0 • Published 1 year ago

@hugov/byte-views v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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