From be83a8f382cf2fea98161bfd6d51719aacbf9aa9 Mon Sep 17 00:00:00 2001 From: Fulup Ar Foll Date: Thu, 28 Jan 2016 16:30:12 +0100 Subject: Update JSON API --- .../bower_components/jszip/lib/uint8ArrayReader.js | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 afm-client/bower_components/jszip/lib/uint8ArrayReader.js (limited to 'afm-client/bower_components/jszip/lib/uint8ArrayReader.js') 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; -- cgit 1.2.3-korg