@bugsplat/elfy
Version:
Tiny utility for parsing ELF/SELF files.
35 lines (34 loc) • 1.23 kB
TypeScript
/// <reference types="node" />
/**
* Interface for reading byte ranges from a data source.
* This abstraction allows the ELF parser to work with different backends:
* - Browser: Blob/File objects
* - Node.js: FileHandle or custom implementations
*/
export interface DataSource {
/**
* Read a range of bytes from the data source.
* @param offset - Starting byte offset
* @param length - Number of bytes to read
* @returns Promise resolving to the requested bytes
*/
read(offset: number, length: number): Promise<Uint8Array>;
}
/**
* DataSource implementation for Blob/File objects.
* Works in browsers with File objects from <input type="file"> or fetch responses.
*/
export declare class BlobDataSource implements DataSource {
private blob;
constructor(blob: Blob);
read(offset: number, length: number): Promise<Uint8Array>;
}
/**
* DataSource implementation for an in-memory Uint8Array or ArrayBuffer.
* Useful for small files or when the entire file is already in memory.
*/
export declare class BufferDataSource implements DataSource {
private data;
constructor(data: Uint8Array | ArrayBuffer);
read(offset: number, length: number): Promise<Uint8Array>;
}