vlt / docs

  • PricingBenchmarks (opens in new window)Community (opens in new window)Feedback
  • Overview
    • Overview
    • browser
    • index
    • Reference
  • Type Aliases
  • Delimiter
  • DepID
  • DepIDTuple
  • Variables
  • delimiter
  • Functions
  • asDepID()
  • baseDepID()
  • getId()
  • getTuple()
  • hydrate()
  • hydrateTuple()
  • isDepID()
  • isPackageNameConfused()
  • joinDepIDTuple()
  • joinExtra()
  • resetCaches()
  • splitDepID()
  • splitExtra()
  1. Client
  2. /
  3. API Reference
  4. /
  5. @vltpkg/dep-id
  6. /
  7. browser

browser

Type Aliases

Delimiter

TypeScript
type Delimiter = "~";

Defined in: browser.ts:11


DepID

TypeScript
type DepID = 
  | `${"" | "git"}${Delimiter}${string}${Delimiter}${string}${Delimiter}${string}`
  | `${"" | "git"}${Delimiter}${string}${Delimiter}${string}`
  | `${"file" | "remote" | "workspace"}${Delimiter}${string}${Delimiter}${string}`
  | `${"file" | "remote" | "workspace"}${Delimiter}${string}`;

Defined in: browser.ts:39

Dependency IDs are a URI-encoded set of strings, separated by the Delimiter character ('~').

The first entry is always the specifier type. The rest depend on the type. git, registry, and workspace entries have 3 fields, the rest have 2.

  • registry: 'registry~<registry>~name@specifier' The <registry> portion can be a known named registry name, or a url to a registry. If empty, it is the default registry. Examples:
    • ~~some-package@2.0.1
    • ~npm~whatever@1.2.3
    • ~http%3A%2F%2Fvlt.sh%2F~x@1.2.3
  • git: 'git~<git remote>~<git selector>'. For example:
    • git~github:user/project~branchname
    • git~git%2Bssh%3A%2F%2Fuser%40host%3Aproject.git~semver:1.x
  • workspace: 'workspace~<path>'. For example:
    • workspace~src/mything
  • remote: 'remote~<url>'
  • file: 'file~<path>'

Lastly, the final portion can contain arbitrary string data, and is used to store peer dep resolutions to maintain the peerDep contract.


DepIDTuple

TypeScript
type DepIDTuple = 
  | ["git", string, string, string]
  | ["registry", string, string, string]
  | ["file", string, string]
  | ["remote", string, string]
  | ["workspace", string, string];

Defined in: browser.ts:48

A DepID, split apart and URI-decoded

Variables

delimiter

TypeScript
const delimiter: Delimiter = '~';

Defined in: browser.ts:10

Functions

asDepID()

TypeScript
function asDepID(str): DepID

Defined in: browser.ts:86

Parameters

ParameterType
strstring

Returns

DepID


baseDepID()

TypeScript
function baseDepID(id): DepID

Defined in: browser.ts:330

Retrieves the base DepID for a given depID, ignoring any extra information that may be present.

Parameters

ParameterType
idstring

Returns

DepID


getId()

TypeScript
function getId(
   spec, 
   mani, 
   extra?): DepID

Defined in: browser.ts:626

Get the DepID for a given Spec and Manifest. The Manifest is used to get the name and version, if possible. If not found in the manifest, registry ID types will use the name or bareSpec from the specifier, so at least there's something to use later.

Parameters

ParameterType
specSpec
maniPick<Manifest, "name" | "version">
extra?string

Returns

DepID


getTuple()

TypeScript
function getTuple(
   spec, 
   mani, 
   extra?): DepIDTuple

Defined in: browser.ts:531

Get the DepIDTuple for a given Spec and Manifest. The Manifest is used to get the name and version, if possible. If not found in the manifest, registry ID types will use the name or bareSpec from the specifier, so at least there's something to use later.

Parameters

ParameterType
specSpec
maniPick<Manifest, "name" | "version">
extra?string

Returns

DepIDTuple


hydrate()

TypeScript
function hydrate(
   id, 
   name?, 
   options?): Spec

Defined in: browser.ts:346

Turn a DepID into a Spec object

Parameters

ParameterType
idDepID
name?string
options?SpecOptions

Returns

Spec


hydrateTuple()

TypeScript
function hydrateTuple(
   tuple, 
   name?, 
   options?): Spec

Defined in: browser.ts:365

Turn a DepIDTuple into a Spec object

Parameters

ParameterType
tupleDepIDTuple
name?string
options?SpecOptions

Returns

Spec


isDepID()

TypeScript
function isDepID(str): str is DepID

Defined in: browser.ts:81

Parameters

ParameterType
strunknown

Returns

str is DepID


isPackageNameConfused()

TypeScript
function isPackageNameConfused(spec?, name?): boolean

Defined in: browser.ts:614

Checks for a potentially manifest-confused package name. Returns true if the package name is confused, false otherwise.

Parameters

ParameterType
spec?Spec
name?string

Returns

boolean


joinDepIDTuple()

TypeScript
function joinDepIDTuple(list): DepID

Defined in: browser.ts:99

turn a DepIDTuple into a DepID

Parameters

ParameterType
listDepIDTuple

Returns

DepID


joinExtra()

TypeScript
function joinExtra(__namedParameters): undefined | string

Defined in: browser.ts:635

Join a modifier and a peer set hash into a single "extra" string.

Parameters

ParameterType
__namedParameters{ modifier: string; peerSetHash: string; }
__namedParameters.modifier?string
__namedParameters.peerSetHash?string

Returns

undefined | string


resetCaches()

TypeScript
function resetCaches(): void

Defined in: browser.ts:679

Reset internal caches. This should be used when options change since they're not take into account in the memoization keys.

Returns

void


splitDepID()

TypeScript
function splitDepID(id): DepIDTuple

Defined in: browser.ts:285

turn a DepID into a DepIDTuple

Parameters

ParameterType
idstring

Returns

DepIDTuple


splitExtra()

TypeScript
function splitExtra(extra): object

Defined in: browser.ts:651

Split an "extra" string into a modifier and a peerSetHash.

Parameters

ParameterType
extrastring

Returns

object

NameType
modifier?string
peerSetHash?string

Previous@vltpkg/dep-idNextindex

On this page

  • Type Aliases
  • Delimiter
  • DepID
  • DepIDTuple
  • Variables
  • delimiter
  • Functions
  • asDepID()
  • baseDepID()
  • getId()
  • getTuple()
  • hydrate()
  • hydrateTuple()
  • isDepID()
  • isPackageNameConfused()
  • joinDepIDTuple()
  • joinExtra()
  • resetCaches()
  • splitDepID()
  • splitExtra()

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