UNPKG

@foxglove/ulog

Version:
27 lines 780 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BlobReader = void 0; // browser reader for Blob|File objects class BlobReader { #blob; constructor(blob) { this.#blob = blob; } size() { return this.#blob.size; } async open() { return this.size(); } /** * Read `length` bytes starting from `offset` bytes. */ async read(offset, length) { if (offset + length > this.size()) { throw new Error(`Read of ${length} bytes at offset ${offset} exceeds blob size ${this.size()}`); } return new Uint8Array(await this.#blob.slice(offset, offset + length).arrayBuffer()); } } exports.BlobReader = BlobReader; //# sourceMappingURL=BlobReader.js.map