tar
Version:
tar for JavaScript
82 lines • 3.54 kB
TypeScript
import { type Codec } from './codec.js';
import { type ReadOptions, type ReadOptionsSync, type TarInput, type TarInputSync } from './options.js';
import { Parser } from './parser.js';
import { ReadEntry, ReadEntrySync, type BodySource, type BodySourceSync, type EntryData } from './read-entry.js';
export declare const headLength: (codecs: Codec[]) => number;
export declare const findCodec: (codecs: Codec[], head: Uint8Array, file?: string) => Codec | undefined;
/**
* Gets entries and the parts of their bodies from a `Parser`. The
* readers use it. It does not read input.
*/
export declare class EntryCursor<E extends EntryData> {
parser: Parser<E>;
/** The entry that has a body to read now. */
current?: E;
/** True after the end of the archive. */
ended: boolean;
constructor(parser: Parser<E>);
/**
* The next entry that is not ignored. `null` at the end of the
* archive. `undefined` if the parser needs more input. The rest of
* the body of the entry before it is skipped.
*/
entry(): E | null | undefined;
/**
* The next part of the body of `entry`. `null` at the end of the
* body. `undefined` if the parser needs more input.
*/
body(entry: E): Uint8Array | null | undefined;
}
/**
* Reads the entries of an archive from async input. It is the
* iterator that `entries()` returns.
*
* Input is read only when the consumer asks for the next entry or
* for more of a body. `poll()` and `fill()` do the same work as
* `next()`, with no promise for an entry that is in memory.
*/
export declare class TarReader implements AsyncIterableIterator<ReadEntry, undefined>, BodySource {
#private;
parser: Parser<ReadEntry>;
constructor(input: TarInput, opt?: ReadOptions);
/**
* The next entry, if it is in memory. `null` at the end of the
* archive. `undefined` if more input is needed: then await `fill()`
* and call this again.
*/
poll(): ReadEntry | null | undefined;
readBody(entry: ReadEntry): Uint8Array | null | undefined;
/** Read one chunk of input, and give it to the parser. */
fill(): Promise<void>;
next(): Promise<IteratorResult<ReadEntry, undefined>>;
/** Stop reading, and release the input. */
return(): Promise<IteratorResult<ReadEntry, undefined>>;
[Symbol.asyncIterator](): this;
}
/**
* Reads the entries of an archive from sync input. It is the
* iterator that `entriesSync()` returns.
*/
export declare class TarReaderSync implements IterableIterator<ReadEntrySync, undefined>, BodySourceSync {
#private;
parser: Parser<ReadEntrySync>;
constructor(input: TarInputSync, opt?: ReadOptionsSync);
readBody(entry: ReadEntrySync): Uint8Array | null;
next(): IteratorResult<ReadEntrySync, undefined>;
/** Stop reading, and release the input. */
return(): IteratorResult<ReadEntrySync, undefined>;
[Symbol.iterator](): this;
}
/**
* Read the entries of an archive. Gzip input is decompressed.
*
* Read the body of an entry before the next entry: when the iterator
* moves on, the rest of the body is skipped.
*/
export declare const entries: (input: TarInput, opt?: ReadOptions) => AsyncIterableIterator<ReadEntry, undefined>;
/**
* Read the entries of an archive with no promises. Compressed input
* needs a codec with a `decompressSync` function in `opt.codecs`.
*/
export declare const entriesSync: (input: TarInputSync, opt?: ReadOptionsSync) => IterableIterator<ReadEntrySync, undefined>;
//# sourceMappingURL=entries.d.ts.map