_toBufferView.js 406 B

123456789101112131415
  1. define(['./_getByteLength'], function (_getByteLength) {
  2. // Internal function to wrap or shallow-copy an ArrayBuffer,
  3. // typed array or DataView to a new view, reusing the buffer.
  4. function toBufferView(bufferSource) {
  5. return new Uint8Array(
  6. bufferSource.buffer || bufferSource,
  7. bufferSource.byteOffset || 0,
  8. _getByteLength(bufferSource)
  9. );
  10. }
  11. return toBufferView;
  12. });