vlt / docs

  • PricingBenchmarks (opens in new window)Community (opens in new window)Feedback
  • Overview
    • Overview
    • clonefile
    • link-tree
    • index
    • placement-pool
    • placement-worker
    • pool
    • Reference
    • store-entry
    • store-index
    • unpack
  • Type Aliases
  • FileEntry
  • Functions
  • cacheEntryBody()
  • checkFs()
  • storeLayout()
  • tmpName()
  • unpack()
  • unpackCacheEntryParallel()
  • unpackCacheEntrySync()
  • 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:150

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

cacheEntryBody()

TypeScript
function cacheEntryBody(entry): Buffer

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

The tarball inside a vlt cache entry file: the file starts with a 4-byte big-endian length of the head, and the body follows the head. The length is read from the same bytes as the body, so an entry that cache-unzip rewrote with a different head is still read correctly.

Parameters

ParameterType
entryBuffer

Returns

Buffer


checkFs()

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

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

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:653

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:415

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:295

Parameters

ParameterType
tarDataBuffer
targetstring
format?TarballFormat

Returns

Promise<void>


unpackCacheEntryParallel()

TypeScript
function unpackCacheEntryParallel(
   file, 
   target, 
format?): Promise<void>

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

Same, inflating on libuv's threadpool. See unpackParallel.

Parameters

ParameterType
filestring
targetstring
format?TarballFormat

Returns

Promise<void>


unpackCacheEntrySync()

TypeScript
function unpackCacheEntrySync(
   file, 
   target, 
   format?): void

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

Unpack the tarball in the vlt cache entry file. See cacheEntryBody.

Parameters

ParameterType
filestring
targetstring
format?TarballFormat

Returns

void


unpackFileParallel()

TypeScript
function unpackFileParallel(
   file, 
   target, 
   offset, 
format?): Promise<void>

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

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:371

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:336

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:307

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:715

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
  • cacheEntryBody()
  • checkFs()
  • storeLayout()
  • tmpName()
  • unpack()
  • unpackCacheEntryParallel()
  • unpackCacheEntrySync()
  • 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