diff --git a/lib/io/event-stream.ts b/lib/io/event-stream.ts index a94e79a6..1ef34fc8 100644 --- a/lib/io/event-stream.ts +++ b/lib/io/event-stream.ts @@ -35,6 +35,7 @@ export function readableStream(func: (stream: any, i: number) => Promise(streamName: string, offset: number, next: (data: ReadResult) => Promise): Promise { const streamEntry = this.dirEntry.streams[streamName]; + /* istanbul ignore if */ if (!streamEntry) { throw new Error('No such stream "' + streamName + '" in document.'); } @@ -366,6 +370,7 @@ export class Storage { // read missing sectors const remainingLen = -len - resultBuffer.length; const numSecs = Math.ceil(remainingLen / secSize); + /* istanbul ignore if */ if (remainingLen > bytes - storageOffset) { throw new Error(`Cannot read ${remainingLen} bytes when only ${bytes - storageOffset} remain in stream.`); } @@ -407,6 +412,7 @@ export class Storage { return new Promise((resolve, reject) => { const strm = this.stream(key, offset, bytesToRead); const bufs: Buffer[] = []; + /* istanbul ignore if */ if (!strm) { return reject(new Error('No such stream "' + key + '".')); } @@ -455,6 +461,7 @@ export class OleCompoundDoc extends EventEmitter { return doc; } + /* istanbul ignore next: Don't currently need this (at all) */ public async readWithCustomHeader(size: number): Promise { this.skipBytes = size; await this.openFile(); @@ -477,10 +484,10 @@ export class OleCompoundDoc extends EventEmitter { return this.rootStorage.storage(storageName); } - public stream(streamName: string, offset: number = 0, len: number = -1) { - this.assertLoaded(); - return this.rootStorage.stream(streamName, offset, len); - } + // public stream(streamName: string, offset: number = 0, len: number = -1) { + // this.assertLoaded(); + // return this.rootStorage.stream(streamName, offset, len); + // } public async readSector(secId: number, offset: number = 0, bytesToRead: number = 0) { this.assertLoaded(); @@ -553,6 +560,7 @@ export class OleCompoundDoc extends EventEmitter { } private assertLoaded() { + /* istanbul ignore if */ if (!this.fd) { throw new Error('Document must be loaded first.'); } @@ -615,6 +623,7 @@ export class OleCompoundDoc extends EventEmitter { private async readSSAT(): Promise { const secIds = this.SAT.getSecIdChain(this.header.SSATSecId); + /* istanbul ignore if */ if (secIds.length !== this.header.SSATSize) { throw new Error('Invalid Short Sector Allocation Table'); } @@ -649,6 +658,7 @@ export class OleCompoundDoc extends EventEmitter { private async read(buffer: Buffer, offset: number, length: number, position: number): Promise<[ number, Buffer ]> { return new Promise((resolve, reject) => { read(this.fd, buffer, offset, length, position, (err, bytesRead, data) => { + /* istanbul ignore if */ if (err) { reject(err); return;