/* istanbul ignore next */
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
define(["require", "exports", "../decode-stream"], function (require, exports, decode_stream_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _PdfAsciiHexStream = (function (_super) {
__extends(_PdfAsciiHexStream, _super);
function _PdfAsciiHexStream(str, maybeLength) {
var _this = this;
if (maybeLength) {
maybeLength *= 0.5;
}
_this = _super.call(this, maybeLength) || this;
_this.stream = str;
_this.firstDigit = -1;
return _this;
}
_PdfAsciiHexStream.prototype.readBlock = function () {
var blockSize = 8000;
var bytes = this.stream.getBytes(blockSize);
if (!bytes.length) {
this.eof = true;
return;
}
var maxDecodeLength = (bytes.length + 1) >> 1;
var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
var bufferLength = this.bufferLength;
var firstDigit = this.firstDigit;
for (var _i = 0, bytes_1 = bytes; _i < bytes_1.length; _i++) {
var ch = bytes_1[_i];
var digit = void 0;
if (ch >= 0x30 && ch <= 0x39) {
digit = ch & 0x0f;
}
else if ((ch >= 0x41 && ch <= 0x46) ||
(ch >= 0x61 && ch <= 0x66)) {
digit = (ch & 0x0f) + 9;
}
else if (ch === 0x3e) {
this.eof = true;
break;
}
else {
continue;
}
if (firstDigit < 0) {
firstDigit = digit;
}
else {
buffer[bufferLength++] = (firstDigit << 4) | digit;
firstDigit = -1;
}
}
if (firstDigit >= 0 && this.eof) {
buffer[bufferLength++] = firstDigit << 4;
firstDigit = -1;
}
this.firstDigit = firstDigit;
this.bufferLength = bufferLength;
};
return _PdfAsciiHexStream;
}(decode_stream_1._PdfDecodeStream));
exports._PdfAsciiHexStream = _PdfAsciiHexStream;
});
|