2 var DataReader = require('./dataReader');
3 var utils = require('./utils');
5 function StringReader(data, optimizedBinaryString) {
7 if (!optimizedBinaryString) {
8 this.data = utils.string2binary(this.data);
10 this.length = this.data.length;
13 StringReader.prototype = new DataReader();
15 * @see DataReader.byteAt
17 StringReader.prototype.byteAt = function(i) {
18 return this.data.charCodeAt(i);
21 * @see DataReader.lastIndexOfSignature
23 StringReader.prototype.lastIndexOfSignature = function(sig) {
24 return this.data.lastIndexOf(sig);
27 * @see DataReader.readData
29 StringReader.prototype.readData = function(size) {
30 this.checkOffset(size);
31 // this will work because the constructor applied the "& 0xff" mask.
32 var result = this.data.slice(this.index, this.index + size);
36 module.exports = StringReader;