TrinetraLabs/Placebo_AI
0
1"use strict";2var DataReader = require("./DataReader");3var utils = require("../utils");4 5function StringReader(data) {6 DataReader.call(this, data);7}8utils.inherits(StringReader, DataReader);9/**10 * @see DataReader.byteAt11 */12StringReader.prototype.byteAt = function(i) {13 return this.data.charCodeAt(this.zero + i);14};15/**16 * @see DataReader.lastIndexOfSignature17 */18StringReader.prototype.lastIndexOfSignature = function(sig) {19 return this.data.lastIndexOf(sig) - this.zero;20};21/**22 * @see DataReader.readAndCheckSignature23 */24StringReader.prototype.readAndCheckSignature = function (sig) {25 var data = this.readData(4);26 return sig === data;27};28/**29 * @see DataReader.readData30 */31StringReader.prototype.readData = function(size) {32 this.checkOffset(size);33 // this will work because the constructor applied the "& 0xff" mask.34 var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);35 this.index += size;36 return result;37};38module.exports = StringReader;39 