unpack
Type Aliases
FileEntry
type FileEntry = object;Defined in: tar/src/unpack.ts:149
A file parsed out of a tarball, at its destination path.
Type declaration
| Name | Type | Description |
|---|---|---|
body | Buffer | - |
dir | false | - |
executable | boolean | written with the exec bit: world-executable in the tar header |
path | string | - |
Functions
checkFs()
function checkFs(
h,
tarDir,
target): h is { path: string }Defined in: tar/src/unpack.ts:257
Parameters
| Parameter | Type |
|---|---|
h | { path: string; } |
h.path? | string |
tarDir | undefined | string |
target | string |
Returns
h is { path: string }
storeLayout()
function storeLayout(
tarData,
dir,
format?): objectDefined in: tar/src/unpack.ts:604
What a tarball explodes to in the global store at dir: its sidecar
index, files and package.json bin target paths. Same parsing and
path safety as unpackSync, and the same format rule -- only
brotli has to be declared. No IO. Throws if the tarball has no valid
package.json.
Parameters
| Parameter | Type |
|---|---|
tarData | Buffer |
dir | string |
format? | TarballFormat |
Returns
object
| Name | Type |
|---|---|
binFiles | string[] |
files | FileEntry[] |
index | StoreIndex |
tmpName()
function tmpName(target): stringDefined in: tar/src/unpack.ts:366
Sibling temp path used to build target before renaming it in.
Parameters
| Parameter | Type |
|---|---|
target | string |
Returns
string
unpack()
function unpack(
tarData,
target,
format?): Promise<void>Defined in: tar/src/unpack.ts:294
Parameters
| Parameter | Type |
|---|---|
tarData | Buffer |
target | string |
format? | TarballFormat |
Returns
Promise<void>
unpackFileParallel()
function unpackFileParallel(
file,
target,
offset,
format?): Promise<void>Defined in: tar/src/unpack.ts:340
unpackParallel reading the tarball from a file, so the read
comes off the main thread as well. See unpackFileSync for
what offset is for.
Parameters
| Parameter | Type | Default value |
|---|---|---|
file | string | undefined |
target | string | undefined |
offset | number | 0 |
format? | TarballFormat | undefined |
Returns
Promise<void>
unpackFileSync()
function unpackFileSync(
file,
target,
offset,
format?): voidDefined in: tar/src/unpack.ts:357
Unpack a tarball straight from a file on disk, skipping offset
leading bytes. Used to extract from a cache entry in place, so the
tarball never lands in the registry client's in-memory cache.
Parameters
| Parameter | Type | Default value |
|---|---|---|
file | string | undefined |
target | string | undefined |
offset | number | 0 |
format? | TarballFormat | undefined |
Returns
void
unpackParallel()
function unpackParallel(
tarData,
target,
format?): Promise<void>Defined in: tar/src/unpack.ts:327
Inflate off the main thread, then write the files on it.
zlib's async API hands the decompress to libuv's threadpool, so
concurrent extractions inflate in parallel -- on UV_THREADPOOL_SIZE
threads, 4 by default -- while the main thread stays free. The writes
then take the sync path, which is faster than the async writers (a
libuv round trip per file costs more than the IO itself).
Splitting the two is the whole point: parallel decompression without
giving up the fast writer. It matters most for brotli, whose inflate
costs more CPU than gzip's, but it speeds up .tgz installs too.
Parameters
| Parameter | Type |
|---|---|
tarData | Buffer |
target | string |
format? | TarballFormat |
Returns
Promise<void>
unpackSync()
function unpackSync(
tarData,
target,
format?): voidDefined in: tar/src/unpack.ts:306
Same as unpack, but blocking. Faster: the async writers pay a libuv round trip per file, which costs more than the IO itself.
Parameters
| Parameter | Type |
|---|---|
tarData | Buffer |
target | string |
format? | TarballFormat |
Returns
void
unpackToStoreSync()
function unpackToStoreSync(
tarData,
dir,
format?): objectDefined in: tar/src/unpack.ts:666
Explode a tarball into dir for the global store and
return its sidecar index (see storeLayout), written straight
into dir (which must not exist; the caller renames it into place).
Same modes as unpackSync followed by reify's bin chmod.
Throws, writing nothing, without a valid package.json. Removes dir
on failure.
Parameters
| Parameter | Type |
|---|---|
tarData | Buffer |
dir | string |
format? | TarballFormat |
Returns
object
| Name | Type |
|---|---|
index | StoreIndex |
References
TarballFormat
Re-exports TarballFormat