vlt / docs

  • PricingBenchmarks (opens in new window)Community (opens in new window)Feedback
  • Overview
    • Overview
    • clonefile
    • link-tree
    • index
    • pool
    • Reference
    • store-entry
    • store-index
    • unpack
  • Type Aliases
  • FileEntry
  • Functions
  • checkFs()
  • storeLayout()
  • tmpName()
  • unpack()
  • unpackFileParallel()
  • unpackFileSync()
  • unpackParallel()
  • unpackSync()
  • unpackToStoreSync()
  • References
  • TarballFormat
  1. Client
  2. /
  3. API Reference
  4. /
  5. @vltpkg/tar
  6. /
  7. unpack

unpack

Type Aliases

FileEntry

TypeScript
type FileEntry = object;

Defined in: tar/src/unpack.ts:149

A file parsed out of a tarball, at its destination path.

Type declaration

NameTypeDescription
bodyBuffer-
dirfalse-
executablebooleanwritten with the exec bit: world-executable in the tar header
pathstring-

Functions

checkFs()

TypeScript
function checkFs(
   h, 
   tarDir, 
   target): h is { path: string }

Defined in: tar/src/unpack.ts:257

Parameters

ParameterType
h{ path: string; }
h.path?string
tarDirundefined | string
targetstring

Returns

h is { path: string }


storeLayout()

TypeScript
function storeLayout(
   tarData, 
   dir, 
   format?): object

Defined 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

ParameterType
tarDataBuffer
dirstring
format?TarballFormat

Returns

object

NameType
binFilesstring[]
filesFileEntry[]
indexStoreIndex

tmpName()

TypeScript
function tmpName(target): string

Defined in: tar/src/unpack.ts:366

Sibling temp path used to build target before renaming it in.

Parameters

ParameterType
targetstring

Returns

string


unpack()

TypeScript
function unpack(
   tarData, 
   target, 
format?): Promise<void>

Defined in: tar/src/unpack.ts:294

Parameters

ParameterType
tarDataBuffer
targetstring
format?TarballFormat

Returns

Promise<void>


unpackFileParallel()

TypeScript
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

ParameterTypeDefault value
filestringundefined
targetstringundefined
offsetnumber0
format?TarballFormatundefined

Returns

Promise<void>


unpackFileSync()

TypeScript
function unpackFileSync(
   file, 
   target, 
   offset, 
   format?): void

Defined 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

ParameterTypeDefault value
filestringundefined
targetstringundefined
offsetnumber0
format?TarballFormatundefined

Returns

void


unpackParallel()

TypeScript
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

ParameterType
tarDataBuffer
targetstring
format?TarballFormat

Returns

Promise<void>


unpackSync()

TypeScript
function unpackSync(
   tarData, 
   target, 
   format?): void

Defined 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

ParameterType
tarDataBuffer
targetstring
format?TarballFormat

Returns

void


unpackToStoreSync()

TypeScript
function unpackToStoreSync(
   tarData, 
   dir, 
   format?): object

Defined 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

ParameterType
tarDataBuffer
dirstring
format?TarballFormat

Returns

object

NameType
indexStoreIndex

References

TarballFormat

Re-exports TarballFormat


Previousstore-indexNext@vltpkg/types

On this page

  • Type Aliases
  • FileEntry
  • Functions
  • checkFs()
  • storeLayout()
  • tmpName()
  • unpack()
  • unpackFileParallel()
  • unpackFileSync()
  • unpackParallel()
  • unpackSync()
  • unpackToStoreSync()
  • References
  • TarballFormat

Deploy your package on vlt.io

Publish scoped and private packages, manage organizations and access, and give every developer and CI environment a consistent source for public and private JavaScript dependencies.

Publish now