UNPKG

@tokenizer/range

Version:
35 lines (34 loc) 1.21 kB
export interface IChunk { offset: number; data: Uint8Array; } export interface IChunkRange { startIx: number; endIx: number; insertIx?: number; } /** * Keeps track of data chunks (partial downloaded file fragments). * * Based on "ChunkedFileData" written by António Afonso * https://github.com/aadsm/jsmediatags/blob/master/src/ChunkedFileData.js */ export declare class ChunkedFileData { private readonly _fileData; /** * Adds data to the file storage at a specific offset. */ addData(offset: number, data: Uint8Array): void; hasDataRange(offsetStart: number, offsetEnd: number): boolean; readToBuffer(buffer: Uint8Array, offset: number, position: number, length: number): number; private _concatData; /** * Finds the chunk range that overlaps the [offsetStart-1,offsetEnd+1] range. * When a chunk is adjacent to the offset we still consider it part of the * range (this is the situation of offsetStart-1 or offsetEnd+1). * When no chunks are found `insertIx` denotes the index where the data * should be inserted in the data list (startIx == NOT_FOUND and endIX == * NOT_FOUND). */ private _getChunkRange; }