---
title: "@vltpkg/spec: browser — vlt docs"
description: "Documentation for the vlt client and the vlt registry."
url: "https://docs.vlt.io/client/api-reference/spec/browser"
image: "https://docs.vlt.io/og/client/api-reference/spec/browser"
lang: "en"
---

# browser

## Classes

### Spec

Defined in: spec/src/browser.ts:315

The base, isomorphic Spec implementation.

#### Extended by

- [`Spec`](https://docs.vlt.io/client/api-reference/spec/module_index.md#spec)

#### Implements

- [`SpecLike`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specliketype)<[`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec)>

#### Constructors

##### new Spec()

```ts
new Spec(
   name, 
   bareSpec, 
   options?): Spec
```

Defined in: spec/src/browser.ts:444

###### Parameters

| Parameter  | Type                                                                                       |
| ---------- | ------------------------------------------------------------------------------------------ |
| `name`     | `string`                                                                                   |
| `bareSpec` | `string`                                                                                   |
| `options`? | [`SpecOptions`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptions) |

###### Returns

[`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec)

##### new Spec()

```ts
new Spec(spec, options?): Spec
```

Defined in: spec/src/browser.ts:445

###### Parameters

| Parameter  | Type                                                                                       |
| ---------- | ------------------------------------------------------------------------------------------ |
| `spec`     | `string`                                                                                   |
| `options`? | [`SpecOptions`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptions) |

###### Returns

[`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec)

##### new Spec()

```ts
new Spec(
   spec, 
   bareOrOptions?, 
   options?): Spec
```

Defined in: spec/src/browser.ts:446

###### Parameters

| Parameter        | Type                                                                                                   |
| ---------------- | ------------------------------------------------------------------------------------------------------ |
| `spec`           | `string` \| [`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec)                    |
| `bareOrOptions`? | `string` \| [`SpecOptions`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptions) |
| `options`?       | [`SpecOptions`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptions)             |

###### Returns

[`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec)

#### Properties

| Property                       | Type                                                                                                              | Default value | Description                                                                                                                                                                                                                                       |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bareSpec`                     | `string`                                                                                                          | `undefined`   | just the part AFTER the name, so `1.x` in `foo@1.x`                                                                                                                                                                                               |
| `catalog?`                     | `string`                                                                                                          | `undefined`   | -                                                                                                                                                                                                                                                 |
| `constructor`                  | _typeof_ [`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec)                                  | `undefined`   | The initial value of Object.prototype.constructor is the standard built-in Object constructor.                                                                                                                                                    |
| `conventionalRegistryTarball?` | `string`                                                                                                          | `undefined`   | conventional location of the tarball on the registry, if it can be guessed. This is only attempted if the spec is a registry type, with a single version comparator. This can be used to elide resolved urls that are repetitive and predictable. |
| `distTag?`                     | `string`                                                                                                          | `undefined`   | a dist-tag like 'latest'                                                                                                                                                                                                                          |
| `file?`                        | `string`                                                                                                          | `undefined`   | file path for file:// url specs                                                                                                                                                                                                                   |
| `gitCommittish?`               | `string`                                                                                                          | `undefined`   | the commit value we will check out                                                                                                                                                                                                                |
| `gitRemote?`                   | `string`                                                                                                          | `undefined`   | the git remote to fetch from                                                                                                                                                                                                                      |
| `gitSelector?`                 | `string`                                                                                                          | `undefined`   | the committish, semver range, and/or path portion of a git remote                                                                                                                                                                                 |
| `gitSelectorParsed?`           | [`GitSelectorParsed`](https://docs.vlt.io/client/api-reference/spec/module_index.md#gitselectorparsed-1)          | `undefined`   | the parsed '::'-separated key/value pairs: `semver:<range>` and `path:<subpath>`                                                                                                                                                                  |
| `name`                         | `string`                                                                                                          | `undefined`   | the name portion, so `foo` in `foo@1.x`                                                                                                                                                                                                           |
| `namedGitHost?`                | `string`                                                                                                          | `undefined`   | github, gitlab, bitbucket, gist, etc.                                                                                                                                                                                                             |
| `namedGitHostPath?`            | `string`                                                                                                          | `undefined`   | the path that's parsed when we have a named git host                                                                                                                                                                                              |
| `namedJsrRegistry?`            | `string`                                                                                                          | `undefined`   | -                                                                                                                                                                                                                                                 |
| `namedRegistry?`               | `string`                                                                                                          | `undefined`   | In specs like `foo@npm:bar@1`, this is the 'npm' part. Other registries can be mapped using the `registries` option.                                                                                                                              |
| `options`                      | [`SpecOptionsFilled`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptionsfilled)            | `undefined`   | options passed to the constructor, plus defaults                                                                                                                                                                                                  |
| `overridden`                   | `boolean`                                                                                                         | `false`       | Is this a spec that overrides another spec?                                                                                                                                                                                                       |
| `range?`                       | [`Range`](https://docs.vlt.io/client/api-reference/semver/reference.md#range)                                     | `undefined`   | parsed semver range specifier                                                                                                                                                                                                                     |
| `registry?`                    | `string`                                                                                                          | `undefined`   | registry to consult to resolve this spec                                                                                                                                                                                                          |
| `registrySpec?`                | `string`                                                                                                          | `undefined`   | semver range or dist-tag for resolving against a packument                                                                                                                                                                                        |
| `remoteURL?`                   | `string`                                                                                                          | `undefined`   | URL to download a tarball from, if it can be determined. This is set for url specs of course, but also git remotes on known hosts that provide a gitHostArchive template.                                                                         |
| `scope?`                       | `` `@${string}` ``                                                                                                | `undefined`   | the name's scope, so `@acme` in `@acme/foo@1.x`                                                                                                                                                                                                   |
| `scopeRegistry?`               | `string`                                                                                                          | `undefined`   | if the name is scoped, and there's a registry associated with the scope, then this is that registry                                                                                                                                               |
| `semver?`                      | `string`                                                                                                          | `undefined`   | spec to resolve against available versions                                                                                                                                                                                                        |
| `spec`                         | `string`                                                                                                          | `undefined`   | the full named specifier passed to the constructor                                                                                                                                                                                                |
| `subspec?`                     | [`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec)                                           | `undefined`   | in `bar@npm:foo@1.x`, this is the spec for `foo@1.x`                                                                                                                                                                                              |
| `type`                         | [`SpecType`](https://docs.vlt.io/client/api-reference/spec/module_index.md#spectype)                              | `undefined`   | the type of spec that this is, ultimately                                                                                                                                                                                                         |
| `workspace?`                   | `string`                                                                                                          | `undefined`   | the package name or path of the workspace being referenced                                                                                                                                                                                        |
| `workspaceSpec?`               | `string`                                                                                                          | `undefined`   | the specifier when using `workspace:` specs This can be either a semver range, `*`, `~`, or `^`, if the name is not modified. Or, it can include a workspace package name or path, like `workspace:packages/foo@*` or `workspace:@scope/foo@*`.   |
| `nodejsDependencies?`          | [`NodeJSDependenciesOptions`](https://docs.vlt.io/client/api-reference/spec/browser.md#nodejsdependenciesoptions) | `undefined`   | -                                                                                                                                                                                                                                                 |

#### Accessors

##### final

###### Get Signature

```ts
get final(): Spec & object
```

Defined in: spec/src/browser.ts:413

Return the final entry in the chain of subspecs When deciding which thing to actually fetch, spec.final is the thing to look at.

###### Returns

[`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec) & `object`

###### Implementation of

```ts
SpecLike.final
```

#### Methods

##### \[kCustomInspect]\()

```ts
kCustomInspect: string
```

Defined in: spec/src/browser.ts:872

###### Returns

`string`

##### toString()

```ts
toString(): string
```

Defined in: spec/src/browser.ts:432

Normally, the string value of a Spec is just the string passed in to be parsed. However, in the case of a chain of subspecs, like `foo@npm:bar@npm:baz@npm:quux@latest`, this simplifies out the middle parts of the chain, returning just `foo@npm:quux@latest`

###### Returns

`string`

###### Implementation of

```ts
SpecLike.toString
```

##### parse()

###### Call Signature

```ts
static parse(
   name, 
   bareSpec, 
   options?): Spec
```

Defined in: spec/src/browser.ts:322

Create a Spec object from a full spec, name+bareSpec, or Spec object

Note: If a Spec object is provided, it is returned as-is, without investigating whether the options match.

###### Parameters

| Parameter  | Type                                                                                       |
| ---------- | ------------------------------------------------------------------------------------------ |
| `name`     | `string`                                                                                   |
| `bareSpec` | `string`                                                                                   |
| `options`? | [`SpecOptions`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptions) |

###### Returns

[`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec)

###### Call Signature

```ts
static parse(spec, options?): Spec
```

Defined in: spec/src/browser.ts:327

Create a Spec object from a full spec, name+bareSpec, or Spec object

Note: If a Spec object is provided, it is returned as-is, without investigating whether the options match.

###### Parameters

| Parameter  | Type                                                                                       |
| ---------- | ------------------------------------------------------------------------------------------ |
| `spec`     | `string`                                                                                   |
| `options`? | [`SpecOptions`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptions) |

###### Returns

[`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec)

###### Call Signature

```ts
static parse(spec, options?): Spec
```

Defined in: spec/src/browser.ts:328

Create a Spec object from a full spec, name+bareSpec, or Spec object

Note: If a Spec object is provided, it is returned as-is, without investigating whether the options match.

###### Parameters

| Parameter  | Type                                                                                       |
| ---------- | ------------------------------------------------------------------------------------------ |
| `spec`     | [`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec)                    |
| `options`? | [`SpecOptions`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptions) |

###### Returns

[`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec)

##### parseArgs()

```ts
static parseArgs(specOrBareSpec, opts?): Spec
```

Defined in: spec/src/browser.ts:339

###### Parameters

| Parameter        | Type                                                                                       |
| ---------------- | ------------------------------------------------------------------------------------------ |
| `specOrBareSpec` | `string`                                                                                   |
| `opts`?          | [`SpecOptions`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptions) |

###### Returns

[`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec)

##### parseGitSelector()

```ts
static parseGitSelector(selector, spec?): [GitSelectorParsed, string, Range]
```

Defined in: spec/src/browser.ts:1004

Should only ever be called with the bit that comes AFTER the # in the git remote url.

###### Parameters

| Parameter  | Type                                                                    |
| ---------- | ----------------------------------------------------------------------- |
| `selector` | `string`                                                                |
| `spec`?    | [`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec) |

###### Returns

\[[`GitSelectorParsed`](https://docs.vlt.io/client/api-reference/spec/module_index.md#gitselectorparsed-1), `string`, [`Range`](https://docs.vlt.io/client/api-reference/semver/reference.md#range)]

## Type Aliases

### NodeJSDependenciesOptions

```ts
type NodeJSDependenciesOptions = object;
```

Defined in: spec/src/browser.ts:272

Injects the Node.js dependencies into the Spec class.

#### Type declaration

| Name         | Type         |
| ------------ | ------------ |
| `homedir`    | `homedir`    |
| `isAbsolute` | `isAbsolute` |
| `join`       | `join`       |
| `resolve`    | `resolve`    |
| `winPath`    | `win32`      |

## Variables

### builtinProtocols

```ts
const builtinProtocols: ReadonlySet<string>;
```

Defined in: spec/src/browser.ts:176

Spec prefixes handled natively, not usable as alias names.

---

### defaultGitHostArchives

```ts
const defaultGitHostArchives: object;
```

Defined in: spec/src/browser.ts:35

#### Type declaration

| Name        | Type     | Default value                                                                            |
| ----------- | -------- | ---------------------------------------------------------------------------------------- |
| `bitbucket` | `string` | '<https://bitbucket.org/$1/$2/get/$committish.tar.gz>'                                   |
| `gist`      | `string` | '<https://codeload.github.com/gist/$1/tar.gz/$committish>'                               |
| `github`    | `string` | '<https://codeload.github.com/$1/$2/legacy.tar.gz/$committish>'                          |
| `gitlab`    | `string` | '<https://gitlab.com/api/v4/projects/$1%2F$2/repository/archive.tar.gz?sha=$committish>' |

---

### defaultGitHosts

```ts
const defaultGitHosts: object;
```

Defined in: spec/src/browser.ts:28

#### Type declaration

| Name        | Type     | Default value                           |
| ----------- | -------- | --------------------------------------- |
| `bitbucket` | `string` | 'git+ssh://git@bitbucket.org:$1/$2.git' |
| `gist`      | `string` | 'git+ssh://git@gist.github.com/$1.git'  |
| `github`    | `string` | 'git+ssh://git@github.com:$1/$2.git'    |
| `gitlab`    | `string` | 'git+ssh://git@gitlab.com:$1/$2.git'    |

---

### defaultJsrRegistries

```ts
const defaultJsrRegistries: object;
```

Defined in: spec/src/browser.ts:26

#### Type declaration

| Name  | Type     | Default value           |
| ----- | -------- | ----------------------- |
| `jsr` | `string` | '<https://npm.jsr.io/>' |

---

### defaultRegistries

```ts
const defaultRegistries: object;
```

Defined in: spec/src/browser.ts:21

#### Type declaration

| Name  | Type     | Default value                             |
| ----- | -------- | ----------------------------------------- |
| `gh`  | `string` | '<https://npm.pkg.github.com/>'           |
| `npm` | `string` | '<https://registry.vlt.io/upstream/npm/>' |

---

### defaultRegistryName

```ts
const defaultRegistryName: "npm" = 'npm';
```

Defined in: spec/src/browser.ts:19

---

### defaultScopeRegistries

```ts
const defaultScopeRegistries: object;
```

Defined in: spec/src/browser.ts:59

#### Type declaration

| Name   | Type     | Default value           |
| ------ | -------- | ----------------------- |
| `@jsr` | `string` | '<https://npm.jsr.io/>' |

---

### gitHostWebsites

```ts
const gitHostWebsites: object;
```

Defined in: spec/src/browser.ts:52

These are just for legacy support of urls that are supported by npm and observed in the wild.

Not configurable, because no more will be added. If you wish to define custom git hosts, use it with the `'git-hosts'` and `'git-host-archives'` options.

#### Type declaration

| Name        | Type     | Default value                |
| ----------- | -------- | ---------------------------- |
| `bitbucket` | `string` | '<https://bitbucket.org/>'   |
| `gist`      | `string` | '<https://gist.github.com/>' |
| `github`    | `string` | '<https://github.com/>'      |
| `gitlab`    | `string` | '<https://gitlab.com/>'      |

---

### kCustomInspect

```ts
const kCustomInspect: typeof kCustomInspect;
```

Defined in: spec/src/browser.ts:17

## Functions

### currentDefaultRegistryName()

```ts
function currentDefaultRegistryName(registry, options): undefined | string
```

Defined in: spec/src/browser.ts:296

Retrieves the short configured name of the default registry if one is available.

#### Parameters

| Parameter  | Type                                                                                       |
| ---------- | ------------------------------------------------------------------------------------------ |
| `registry` | `string`                                                                                   |
| `options`  | [`SpecOptions`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptions) |

#### Returns

`undefined` | `string`

---

### getNormalizeFile()

```ts
function getNormalizeFile(opts?): (bareSpec, spec) => [string, string]
```

Defined in: spec/src/browser.ts:1080

#### Parameters

| Parameter | Type                                                                                                              |
| --------- | ----------------------------------------------------------------------------------------------------------------- |
| `opts`?   | [`NodeJSDependenciesOptions`](https://docs.vlt.io/client/api-reference/spec/browser.md#nodejsdependenciesoptions) |

#### Returns

`Function`

##### Parameters

| Parameter  | Type                                                                    |
| ---------- | ----------------------------------------------------------------------- |
| `bareSpec` | `string`                                                                |
| `spec`     | [`Spec`](https://docs.vlt.io/client/api-reference/spec/browser.md#spec) |

##### Returns

\[`string`, `string`]

---

### getOptions()

```ts
function getOptions(options?): SpecOptionsFilled
```

Defined in: spec/src/browser.ts:137

Fill in the defaults for a set of spec options.

Memoized per options object: the same object comes back until one of the fields read here is reassigned. The result is shared, so treat it (and `spec.options`) as read-only.

#### Parameters

| Parameter  | Type                                                                                       |
| ---------- | ------------------------------------------------------------------------------------------ |
| `options`? | [`SpecOptions`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptions) |

#### Returns

[`SpecOptionsFilled`](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptionsfilled)

---

### isSpec()

```ts
function isSpec(spec): spec is Spec
```

Defined in: spec/src/browser.ts:280

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `spec`    | `unknown` |

#### Returns

`spec is Spec`

## References

### assertPathSafeName

Re-exports [assertPathSafeName](https://docs.vlt.io/client/api-reference/spec/module_index.md#assertpathsafename)

### GitSelectorParsed

Re-exports [GitSelectorParsed](https://docs.vlt.io/client/api-reference/spec/module_index.md#gitselectorparsed-1)

### isPathSafeName

Re-exports [isPathSafeName](https://docs.vlt.io/client/api-reference/spec/module_index.md#ispathsafename)

### Scope

Re-exports [Scope](https://docs.vlt.io/client/api-reference/spec/module_index.md#scope-1)

### SpecLike

Re-exports [SpecLike](https://docs.vlt.io/client/api-reference/spec/module_index.md#specliketype)

### SpecLikeBase

Re-exports [SpecLikeBase](https://docs.vlt.io/client/api-reference/spec/module_index.md#speclikebase)

### SpecOptions

Re-exports [SpecOptions](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptions)

### SpecOptionsFilled

Re-exports [SpecOptionsFilled](https://docs.vlt.io/client/api-reference/spec/module_index.md#specoptionsfilled)

### SpecType

Re-exports [SpecType](https://docs.vlt.io/client/api-reference/spec/module_index.md#spectype)
