Skip to content

index | @vltpkg/dep-id

Type Aliases

Delimiter

type Delimiter: "·";

Defined in

index.ts:6


DepID

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}`;

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:
  • 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.

Defined in

index.ts:33


DepIDTuple

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

A DepID, split apart and URI-decoded

Defined in

index.ts:42

Variables

delimiter

const delimiter: Delimiter = '·'

Defined in

index.ts:5

Functions

asDepID()

function asDepID(str): DepID

Parameters

str: string

Returns

DepID

Defined in

index.ts:72


getId()

function getId(spec, mani): DepID

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

spec: Spec

mani: Manifest

Returns

DepID

Defined in

index.ts:317


getTuple()

function getTuple(spec, mani): DepIDTuple

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

spec: Spec

mani: Manifest

Returns

DepIDTuple

Defined in

index.ts:253


hydrate()

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

Turn a DepID into a Spec object

Parameters

id: DepID

name?: string

options?: SpecOptions = {}

Returns

Spec

Defined in

index.ts:140


hydrateTuple()

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

Turn a DepIDTuple into a Spec object

Parameters

tuple: DepIDTuple

name?: string

options?: SpecOptions = {}

Returns

Spec

Defined in

index.ts:149


isDepID()

function isDepID(str): str is DepID

Parameters

str: unknown

Returns

str is DepID

Defined in

index.ts:69


joinDepIDTuple()

function joinDepIDTuple(list): DepID

turn a DepIDTuple into a DepID

Parameters

list: DepIDTuple

Returns

DepID

Defined in

index.ts:84


splitDepID()

function splitDepID(id): DepIDTuple

turn a DepID into a DepIDTuple

Parameters

id: string

Returns

DepIDTuple

Defined in

index.ts:104