UNPKG

@obsidize/tar-browserify

Version:

Browser-based tar utility for packing and unpacking tar files (stream-capable)

19 lines (18 loc) 552 B
/** * Built-in wrapper for basic in-memory buffers so they * can be transposed to fit the shared `AsyncUint8ArrayLike` format. */ export class InMemoryAsyncUint8Array { constructor(input) { this.input = input; } get byteLength() { return this.input.byteLength; } read(offset, length) { const max = this.input.byteLength; const start = Math.min(offset, max); const end = Math.min(start + length, max); return Promise.resolve(this.input.slice(start, end)); } }