summaryrefslogtreecommitdiffstats
path: root/afm-client/bower_components/jszip/lib/uint8ArrayReader.js
diff options
context:
space:
mode:
authorFulup Ar Foll <fulup@iot.bzh>2016-01-28 16:30:12 +0100
committerFulup Ar Foll <fulup@iot.bzh>2016-01-28 16:30:12 +0100
commitbe83a8f382cf2fea98161bfd6d51719aacbf9aa9 (patch)
tree3fb02337f8d7d308ef7ca7818ecc3d3a6ee05d88 /afm-client/bower_components/jszip/lib/uint8ArrayReader.js
parent1a4ed39bf86b2115eb0f1387d1e988462b492776 (diff)
Update JSON API
Diffstat (limited to 'afm-client/bower_components/jszip/lib/uint8ArrayReader.js')
-rw-r--r--afm-client/bower_components/jszip/lib/uint8ArrayReader.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/afm-client/bower_components/jszip/lib/uint8ArrayReader.js b/afm-client/bower_components/jszip/lib/uint8ArrayReader.js
new file mode 100644
index 0000000..ce8d1a8
--- /dev/null
+++ b/afm-client/bower_components/jszip/lib/uint8ArrayReader.js
@@ -0,0 +1,47 @@
+'use strict';
+var DataReader = require('./dataReader');
+
+function Uint8ArrayReader(data) {
+ if (data) {
+ this.data = data;
+ this.length = this.data.length;
+ this.index = 0;
+ }
+}
+Uint8ArrayReader.prototype = new DataReader();
+/**
+ * @see DataReader.byteAt
+ */
+Uint8ArrayReader.prototype.byteAt = function(i) {
+ return this.data[i];
+};
+/**
+ * @see DataReader.lastIndexOfSignature
+ */
+Uint8ArrayReader.prototype.lastIndexOfSignature = function(sig) {
+ var sig0 = sig.charCodeAt(0),
+ sig1 = sig.charCodeAt(1),
+ sig2 = sig.charCodeAt(2),
+ sig3 = sig.charCodeAt(3);
+ for (var i = this.length - 4; i >= 0; --i) {
+ if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) {
+ return i;
+ }
+ }
+
+ return -1;
+};
+/**
+ * @see DataReader.readData
+ */
+Uint8ArrayReader.prototype.readData = function(size) {
+ this.checkOffset(size);
+ if(size === 0) {
+ // in IE10, when using subarray(idx, idx), we get the array [0x00] instead of [].
+ return new Uint8Array(0);
+ }
+ var result = this.data.subarray(this.index, this.index + size);
+ this.index += size;
+ return result;
+};
+module.exports = Uint8ArrayReader;