Update JSON API
[src/app-framework-demo.git] / afm-client / bower_components / jszip / lib / stringReader.js
1 'use strict';
2 var DataReader = require('./dataReader');
3 var utils = require('./utils');
4
5 function StringReader(data, optimizedBinaryString) {
6     this.data = data;
7     if (!optimizedBinaryString) {
8         this.data = utils.string2binary(this.data);
9     }
10     this.length = this.data.length;
11     this.index = 0;
12 }
13 StringReader.prototype = new DataReader();
14 /**
15  * @see DataReader.byteAt
16  */
17 StringReader.prototype.byteAt = function(i) {
18     return this.data.charCodeAt(i);
19 };
20 /**
21  * @see DataReader.lastIndexOfSignature
22  */
23 StringReader.prototype.lastIndexOfSignature = function(sig) {
24     return this.data.lastIndexOf(sig);
25 };
26 /**
27  * @see DataReader.readData
28  */
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);
33     this.index += size;
34     return result;
35 };
36 module.exports = StringReader;