Ingen beskrivning

Uint8ArrayReader.js 652B

12345678910111213141516171819202122
  1. 'use strict';
  2. var ArrayReader = require('./ArrayReader');
  3. var utils = require('../utils');
  4. function Uint8ArrayReader(data) {
  5. ArrayReader.call(this, data);
  6. }
  7. utils.inherits(Uint8ArrayReader, ArrayReader);
  8. /**
  9. * @see DataReader.readData
  10. */
  11. Uint8ArrayReader.prototype.readData = function(size) {
  12. this.checkOffset(size);
  13. if(size === 0) {
  14. // in IE10, when using subarray(idx, idx), we get the array [0x00] instead of [].
  15. return new Uint8Array(0);
  16. }
  17. var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size);
  18. this.index += size;
  19. return result;
  20. };
  21. module.exports = Uint8ArrayReader;