tar
Version:
tar for JavaScript
82 lines • 2.73 kB
TypeScript
import { Header } from './header.js';
import type { EntryTypeName } from './types.js';
/**
* The content of a `WriteEntry`. `PackSync` takes only a string, a
* `Uint8Array`, or a sync iterable.
*/
export type WriteBody = string | Uint8Array | Blob | ReadableStream<Uint8Array> | AsyncIterable<Uint8Array> | Iterable<Uint8Array>;
/** The metadata of a `WriteEntry`. A `ReadEntry` fits this type. */
export type WriteEntryData = {
path: string;
/** Default `'File'`. */
type?: EntryTypeName;
mode?: number;
uid?: number;
gid?: number;
uname?: string;
gname?: string;
/**
* The number of bytes in the body. Default: the length of a body
* that is a string, a `Uint8Array`, or a `Blob`.
*/
size?: number;
mtime?: Date;
atime?: Date;
ctime?: Date;
linkpath?: string;
dev?: number;
ino?: number;
nlink?: number;
};
/** The options of `WriteEntry.encode`. */
export type EncodeOptions = {
/** A directory to put before the path, and before a hard link target. */
prefix?: string;
/** Write no PAX header for a field that does not fit the header. */
noPax?: boolean;
};
/**
* An entry to write to an archive, in the shape of a `Request`: the
* metadata is in the fields, and the content is `body`.
*
* A pack makes one for each path that it reads from the file system
* and for each entry that it copies from another archive. Make one
* with content from memory, and give it to `Pack.add()`.
*
* `onWriteEntry` gets the entry before its header is written, and can
* change each field.
*/
export declare class WriteEntry {
path: string;
type: EntryTypeName;
/** The permission bits only. */
mode?: number;
uid?: number;
gid?: number;
uname?: string;
gname?: string;
/** The number of bytes in the body. The body must have this many. */
size: number;
mtime?: Date;
atime?: Date;
ctime?: Date;
linkpath?: string;
dev?: number;
ino?: number;
nlink?: number;
/** The content. A string is kept as its UTF-8 bytes. */
body?: Exclude<WriteBody, string>;
/** The path of the file, for an entry that a pack read from a path. */
absolute?: string;
/** The header block, after `encode()`. */
header?: Header;
constructor(data: WriteEntryData, body?: WriteBody);
/**
* Make the header from the fields, and write it to the first 512
* bytes of `block`, which must be zeros. Returns the blocks to
* write before the body: `block`, and before it a PAX header entry
* if a field does not fit the header.
*/
encode(opt?: EncodeOptions, block?: Uint8Array): Uint8Array[];
}
//# sourceMappingURL=write-entry.d.ts.map