nodeBufferReader.js 545 B

123456789101112131415161718192021
  1. 'use strict';
  2. var Uint8ArrayReader = require('./uint8ArrayReader');
  3. function NodeBufferReader(data) {
  4. this.data = data;
  5. this.length = this.data.length;
  6. this.index = 0;
  7. this.zero = 0;
  8. }
  9. NodeBufferReader.prototype = new Uint8ArrayReader();
  10. /**
  11. * @see DataReader.readData
  12. */
  13. NodeBufferReader.prototype.readData = function(size) {
  14. this.checkOffset(size);
  15. var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
  16. this.index += size;
  17. return result;
  18. };
  19. module.exports = NodeBufferReader;