UNPKG

tar

Version:
115 lines • 6.26 kB
import type { BrotliOptions, ZlibOptions, ZstdOptions } from 'node:zlib'; import * as core from '../index.js'; import { type FileOption, type NoFileOption, type WithAliases } from '../dealias.js'; import type { PackInput, PackInputSync } from '../pack.js'; import type { ReadEntry, ReadEntrySync } from '../read-entry.js'; export * from '../index.js'; export { TarReaderSync } from '../entries.js'; export { PackSync } from '../pack.js'; export { ReadEntrySync } from '../read-entry.js'; export { UnpackSync } from '../unpack.js'; export { zlibCodecs, codecStream, type ZlibModule } from './codecs.js'; /** Each member of the option type `T`, with `fs` and `cwd` optional. */ export type Loose<T> = T extends unknown ? Omit<T, 'fs' | 'cwd'> & Partial<Pick<T, Extract<keyof T, 'fs' | 'cwd'>>> : never; /** The compression options, with the option types of `node:zlib`. */ export type Zip = { /** Compress with gzip. An object is the options of `zlib.createGzip`. */ gzip?: boolean | ZlibOptions; /** * Compress with brotli. An object is the options of * `zlib.createBrotliCompress`. */ brotli?: boolean | BrotliOptions; /** * Compress with zstd. An object is the options of * `zlib.createZstdCompress`. */ zstd?: boolean | ZstdOptions; }; /** `Loose<T>`, with the compression options of `Zip`. */ export type Packing<T> = Omit<Loose<T>, keyof Zip> & Zip; /** The options of `entries`. */ export type ReadOptions = core.ReadOptions; /** The options of `entriesSync`. */ export type ReadOptionsSync = core.ReadOptionsSync; /** The options of `list`. Set `input` or `file`. */ export type ListOptions = Loose<core.ListOptions>; /** The options of `listSync`. Set `input` or `file`. */ export type ListOptionsSync = Loose<core.ListOptionsSync>; /** The options of `extract`. The default of `cwd` is `process.cwd()`. */ export type ExtractOptions = Loose<core.ExtractOptions>; /** The options of `extractSync`. */ export type ExtractOptionsSync = Loose<core.ExtractOptionsSync>; /** The options of `create`. The default of `cwd` is `process.cwd()`. */ export type CreateOptions = Packing<core.CreateOptions>; /** The options of `createSync`. */ export type CreateOptionsSync = Packing<core.CreateOptionsSync>; /** The options of `replace` and `update`. */ export type ReplaceOptions = Packing<core.ReplaceOptions>; /** The options of `replaceSync` and `updateSync`. */ export type ReplaceOptionsSync = Packing<core.ReplaceOptionsSync>; /** The options of `delete`. */ export type DeleteOptions = Loose<core.DeleteOptions>; /** The options of `deleteSync`. */ export type DeleteOptionsSync = Loose<core.DeleteOptionsSync>; /** * Read the entries of an archive. Gzip, brotli, and zstd input is * decompressed, if the runtime has the format. */ export declare const entries: (input: core.TarInput, opt?: ReadOptions) => AsyncIterableIterator<ReadEntry, undefined>; /** The sync form of `entries`. */ export declare const entriesSync: (input: core.TarInputSync, opt?: ReadOptionsSync) => IterableIterator<ReadEntrySync, undefined>; /** * Call `opt.onEntry` with each entry of an archive. If `files` is * set, only with the entries that it lists, and the entries in the * directories that it lists. */ export declare const list: (opt: WithAliases<ListOptions>, files?: string[]) => Promise<void>; /** The sync form of `list`. */ export declare const listSync: (opt: WithAliases<ListOptionsSync>, files?: string[]) => void; /** * Extract the entries of an archive into the directory `opt.cwd`. * If `files` is set, only the entries that it lists, and the entries * in the directories that it lists. */ export declare const extract: (opt: WithAliases<ExtractOptions>, files?: string[]) => Promise<void>; /** The sync form of `extract`. */ export declare const extractSync: (opt: WithAliases<ExtractOptionsSync>, files?: string[]) => void; /** * Make an archive of the files. With `opt.file`, the archive is * written to that path. With no `opt.file`, the result is a stream * of the bytes of the archive. */ export declare function create(opt: WithAliases<CreateOptions> & FileOption, files: PackInput[]): Promise<void>; export declare function create(opt: WithAliases<CreateOptions> & NoFileOption, files: PackInput[]): ReadableStream<Uint8Array>; export declare function create(opt: WithAliases<CreateOptions>, files: PackInput[]): Promise<void> | ReadableStream<Uint8Array>; /** * The sync form of `create`. With no `opt.file`, the result is an * iterator of the bytes of the archive. */ export declare function createSync(opt: WithAliases<CreateOptionsSync> & FileOption, files: PackInputSync[]): void; export declare function createSync(opt: WithAliases<CreateOptionsSync> & NoFileOption, files: PackInputSync[]): IterableIterator<Uint8Array, undefined>; export declare function createSync(opt: WithAliases<CreateOptionsSync>, files: PackInputSync[]): void | IterableIterator<Uint8Array, undefined>; /** Add the files to the end of an archive file that is not compressed. */ export declare const replace: (opt: WithAliases<ReplaceOptions>, files: PackInput[]) => Promise<void>; /** The sync form of `replace`. */ export declare const replaceSync: (opt: WithAliases<ReplaceOptionsSync>, files: PackInputSync[]) => void; /** * The same as `replace`, but a file is added only if it is newer than * the last entry of the archive that has its path. A directory is * always added, and each path in it is checked. */ export declare const update: (opt: WithAliases<ReplaceOptions>, files: PackInput[]) => Promise<void>; /** The sync form of `update`. */ export declare const updateSync: (opt: WithAliases<ReplaceOptionsSync>, files: PackInputSync[]) => void; /** * Remove entries from an archive file: each entry that `files` lists, * and each entry in a directory that it lists. With `opt.filter`, * only if the filter also returns true. */ declare const del: (opt: WithAliases<DeleteOptions>, files?: string[]) => Promise<void>; /** The sync form of `delete`. */ export declare const deleteSync: (opt: WithAliases<DeleteOptionsSync>, files?: string[]) => void; export { del as delete }; export { create as c, extract as x, list as t, replace as r, update as u }; //# sourceMappingURL=index.d.ts.map