UNPKG

tar

Version:
122 lines • 4.24 kB
import type { Header } from './header.js'; import type { Pax } from './pax.js'; import type { EntryTypeName } from './types.js'; /** * The metadata of one archive entry: the header fields, with the * values of the PAX and GNU extended headers applied. */ export declare class EntryData { #private; /** The header block of the entry. */ header: Header; /** The PAX header that applies to this entry only. */ extended?: Pax; /** The global PAX header in effect. */ globalExtended?: Pax; type: EntryTypeName; path: string; /** The permission bits only. */ mode?: number; uid?: number; gid?: number; uname?: string; gname?: string; /** The number of bytes in the body. */ size: number; mtime?: Date; atime?: Date; ctime?: Date; linkpath?: string; devmaj: number; devmin: number; dev?: number; ino?: number; nlink?: number; /** The absolute path of the entry, when a consumer resolves it. */ absolute?: string; /** * The body is skipped. Set for a type that is not an object of the * file system, and for an entry that the filter refuses. */ ignore: boolean; /** A consumer sets this when it refuses the entry. */ invalid: boolean; /** A consumer sets this when it does not support the type. */ unsupported: boolean; /** * @param win32 change each `\` in `path` and `linkpath` to `/` */ constructor(header: Header, ex?: Pax, gex?: Pax, win32?: boolean); } /** Where a `ReadEntry` gets its body. */ export type BodySource = { /** * The next part of the body of `entry`. `null` at the end of the * body. `undefined` if more input is needed: then await `fill()` * and call this again. Throws if the source moved to a later entry. */ readBody(entry: ReadEntry): Uint8Array | null | undefined; /** Read more input. */ fill(): Promise<void>; }; /** Where a `ReadEntrySync` gets its body. */ export type BodySourceSync = { /** * The next part of the body of `entry`, or `null` at the end of the * body. Throws if the source moved to a later entry. */ readBody(entry: ReadEntrySync): Uint8Array | null; }; /** * An archive entry with its body, in the shape of a `Response`. The * body can be consumed one time, in one way. It must be consumed * before the next entry is read: after that, the rest of it is gone. */ export declare class ReadEntry extends EntryData { #private; constructor(header: Header, ex?: Pax, gex?: Pax, win32?: boolean, source?: BodySource); /** True when the body started to be consumed. */ get bodyUsed(): boolean; /** * The body as a stream. Each chunk is a view into the input, not a * copy. Input is read only when the stream is read. */ get body(): ReadableStream<Uint8Array>; /** The body in a new `Uint8Array`. */ bytes(): Promise<Uint8Array<ArrayBuffer>>; /** The body in a new `ArrayBuffer`. */ arrayBuffer(): Promise<ArrayBuffer>; /** * The body, decoded as UTF-8. As with `Response.text()`, a byte * order mark at the start is not in the text. */ text(): Promise<string>; /** The body in a new `Blob`. */ blob(): Promise<Blob>; } /** * An archive entry with its body, for sync code. The body can be * consumed one time, in one way. It must be consumed before the next * entry is read: after that, the rest of it is gone. */ export declare class ReadEntrySync extends EntryData { #private; constructor(header: Header, ex?: Pax, gex?: Pax, win32?: boolean, source?: BodySourceSync); /** True when the body started to be consumed. */ get bodyUsed(): boolean; /** * The parts of the body. Each one is a view into the input, not a * copy. Input is read only when the iterator is read. */ get body(): IterableIterator<Uint8Array>; /** The body in a new `Uint8Array`. */ bytes(): Uint8Array<ArrayBuffer>; /** The body in a new `ArrayBuffer`. */ arrayBuffer(): ArrayBuffer; /** * The body, decoded as UTF-8. A byte order mark at the start is not * in the text. */ text(): string; } //# sourceMappingURL=read-entry.d.ts.map