Skip to content

Type Aliases

Bugs

type Bugs =
| string
| {
email: string
url: string
}

Defined in: index.ts:155


ConditionalValue

type ConditionalValue =
| ConditionalValue[]
| ConditionalValueObject
| string
| null

Defined in: index.ts:43


ConditionalValueObject

type ConditionalValueObject = object

Defined in: index.ts:39

Index Signature

[k: string]: ConditionalValue

DependencySaveType

type DependencySaveType = DependencyTypeShort | 'implicit'

Defined in: index.ts:551

Unique keys that indicate how a new or updated dependency should be saved back to a manifest.

'implicit' is used to indicate that a dependency should be saved as whatever type it already exists as. If the dependency does not exist, then 'implicit' is equivalent to 'prod', as that is the default save type.


DependencyTypeLong

type DependencyTypeLong =
| 'dependencies'
| 'devDependencies'
| 'optionalDependencies'
| 'peerDependencies'

Defined in: index.ts:526

Name of the package.json keys used to define different types of dependencies.


DependencyTypeShort

type DependencyTypeShort =
| 'dev'
| 'optional'
| 'peer'
| 'peerOptional'
| 'prod'

Defined in: index.ts:535

Unique keys that define different types of dependencies relationship.


Dist

type Dist = object

Defined in: index.ts:20

The Manifest[‘dist’] field present in registry manifests

Type declaration

fileCount?
optional fileCount: number;
integrity?
optional integrity: Integrity;
shasum?
optional shasum: string;
signatures?
optional signatures: object[];
tarball?
optional tarball: string;
unpackedSize?
optional unpackedSize: number;

Exports

type Exports = Exclude<ConditionalValue, null> | ExportsSubpaths

Defined in: index.ts:53


ExportsSubpaths

type ExportsSubpaths = {
[path in '.' | `./${string}`]?: ConditionalValue
}

Defined in: index.ts:49


Funding

type Funding = FundingEntry | FundingEntry[]

Defined in: index.ts:62


FundingEntry

type FundingEntry =
| string
| {
[key: string]: JSONField
type: string
url: string
}

Defined in: index.ts:59


Imports

type Imports = Record<`#${string}`, ConditionalValue>

Defined in: index.ts:57


Integrity

type Integrity = `sha512-${string}`

Defined in: index.ts:14

sha512 SRI string


JSONField

type JSONField =
| JSONField[]
| boolean
| number
| string
| {}
| null
| undefined

Defined in: index.ts:4

anything that can be encoded in JSON


KeyID

type KeyID = `SHA256:${string}`

Defined in: index.ts:17

SHA256 key identifier


Manifest

type Manifest = object

Defined in: index.ts:162

Type declaration

acceptDependencies?
optional acceptDependencies: Record<string, string>;

dependency ranges that are acceptable, but not forced

author?
optional author: Person;

the author of a package

bin?
optional bin: Record<string, string> | string;

executable built and linked by this package

bugs?
optional bugs: Bugs;

where to go to file issues

bundleDependencies?
optional bundleDependencies: string[];

names of dependencies included in the package tarball

contributors?
optional contributors: Person[];

contributors to the package

cpu?
optional cpu: string[] | string;

supported CPU architectures this package can run on

dependencies?
optional dependencies: Record<string, string>;

production dependencies, name:specifier

deprecated?
optional deprecated: string;

a message indicating that this is not to be used

description?
optional description: string;

a short description of the package

devDependencies?
optional devDependencies: Record<string, string>;

development dependencies, name:specifier

dist?
optional dist: Dist;

Only present in Manifests served by a registry. Contains information about the artifact served for this package release.

engines?
optional engines: Record<string, string>;

supported run-time platforms this package can run on

exports?
optional exports: Exports;

named subpath exports

funding?
optional funding: Funding;

URLs that can be visited to fund this project

gitHead?
optional gitHead: string;

the HEAD of the git repo this was published from only present in published packages

gypfile?
optional gypfile: boolean;

npm puts this on published manifests

homepage?
optional homepage: string;

The homepage of the repository

imports?
optional imports: Imports;

named #identifier imports

keywords?
optional keywords: string[];

search keywords

license?
optional license: string;

the license of the package

main?
optional main: string;

the main module, if exports[’.’] is not set

name?
optional name: string;

The name of the package. optional because {} is a valid package.json

optionalDependencies?
optional optionalDependencies: Record<string, string>;

optional dependencies, name:specifier

os?
optional os: string[] | string;

supported operating systems this package can run on

peerDependencies?
optional peerDependencies: Record<string, string>;

peer dependencies, name:specifier

peerDependenciesMeta?
optional peerDependenciesMeta: Record<string, PeerDependenciesMetaValue>;

peer dependencies marked as optional

private?
optional private: boolean;

whether the package is private

repository?
optional repository: Repository;

where the development happens

scripts?
optional scripts: Record<string, string>;

run-script actions for this package

type?
optional type: "commonjs" | "module";

whether this is ESM or CommonJS by default

version?
optional version: string;

The version of the package. optional because {} is a valid package.json


ManifestRegistry

type ManifestRegistry = Manifest &
Required<Pick<Manifest, 'name' | 'version' | 'dist'>>

Defined in: index.ts:235


NormalizedFunding

type NormalizedFunding = NormalizedFundingEntry[]

Defined in: index.ts:71

Normalized funding - always an array of objects


NormalizedFundingEntry

type NormalizedFundingEntry = object

Defined in: index.ts:65

Normalized funding entry - always an object with url and optional additional properties

Type declaration

Index Signature

[key: string]: JSONField
type?
optional type: string;
url
url: string

Packument

type Packument = object

Defined in: index.ts:238

Type declaration

dist-tags
dist-tags: Record<string, string>;
modified?
optional modified: string;
name
name: string
readme?
optional readme: string;
time?
optional time: Record<string, string>;
versions
versions: Record<string, Manifest>

PeerDependenciesMetaValue

type PeerDependenciesMetaValue = object

Defined in: index.ts:33

An object used to mark some peerDeps as optional

Type declaration

optional?
optional optional: boolean;

Person

type Person =
| string
| {
email: string
name: string
url: string
}

Defined in: index.ts:140


RefType

type RefType = 'branch' | 'head' | 'other' | 'pull' | 'tag'

Defined in: index.ts:247


Repository

type Repository =
| string
| {
type: string
url: string
}

Defined in: index.ts:148


RevDoc

type RevDoc = Omit<Packument, 'versions'> & object

Defined in: index.ts:267

An object kind of resembling a packument, but about a git repo.

Type declaration

refs
refs: Record<string, RevDocEntry>

all named things that can be cloned down remotely

shas
shas: Record<string, string[]>

all named shas referenced above

versions
versions: Record<string, RevDocEntry>

all semver-looking tags go in this record


RevDocEntry

type RevDocEntry = Omit<Manifest, 'type'> &
Required<Pick<Manifest, 'version'>> &
object

Defined in: index.ts:252

A representation of a given remote ref in a RevDoc object.

Type declaration

rawRef
rawRef: string

canonical full ref, like refs/tags/blahblah

ref
ref: string

ref as passed git locally

sha
sha: string

sha this references

type
type: RefType

what type of ref this is: ‘branch’, ‘tag’, etc.

Variables

dependencyTypes

const dependencyTypes: Map<DependencyTypeLong, DependencyTypeShort>

Defined in: index.ts:579

Maps between long form names usually used in package.json files to a corresponding short form name, used in lockfiles.


integrityRE

const integrityRE: RegExp

Defined in: index.ts:276


keyIDRE

const keyIDRE: RegExp

Defined in: index.ts:300


longDependencyTypes

const longDependencyTypes: Set<DependencyTypeLong>

Defined in: index.ts:557

A set of the possible long dependency type names, as used in package.json files.


shortDependencyTypes

const shortDependencyTypes: Set<DependencyTypeShort>

Defined in: index.ts:567

A set of the short type keys used to represent dependency relationships.

Functions

asError()

function asError(er, fallbackMessage): Error

Defined in: index.ts:325

Convert an unknown value to an error.

Parameters

er

unknown

fallbackMessage

string = 'Unknown error'

Returns

Error


asIntegrity()

function asIntegrity(i): `sha512-${string}`

Defined in: index.ts:280

Parameters

i

unknown

Returns

`sha512-${string}`


asKeyID()

function asKeyID(k): `SHA256:${string}`

Defined in: index.ts:304

Parameters

k

unknown

Returns

`SHA256:${string}`


asManifest()

function asManifest(m, from?): Manifest

Defined in: index.ts:444

Parameters

m

unknown

from?

(…a) => any

Returns

Manifest


asManifestRegistry()

function asManifestRegistry(m, from?): ManifestRegistry

Defined in: index.ts:467

Parameters

m

unknown

from?

(…a) => any

Returns

ManifestRegistry


asPackument()

function asPackument(p, from?): Packument

Defined in: index.ts:503

Parameters

p

unknown

from?

(…a) => any

Returns

Packument


assertIntegrity()

function assertIntegrity(i): asserts i is `sha512-${string}`

Defined in: index.ts:294

Parameters

i

unknown

Returns

asserts i is `sha512-${string}`


assertKeyID()

function assertKeyID(k): asserts k is `SHA256:${string}`

Defined in: index.ts:318

Parameters

k

unknown

Returns

asserts k is `SHA256:${string}`


assertManifest()

function assertManifest(m): asserts m is Manifest

Defined in: index.ts:481

Parameters

m

unknown

Returns

asserts m is Manifest


assertManifestRegistry()

function assertManifestRegistry(m): asserts m is ManifestRegistry

Defined in: index.ts:486

Parameters

m

unknown

Returns

asserts m is ManifestRegistry


assertPackument()

function assertPackument(m): asserts m is Packument

Defined in: index.ts:517

Parameters

m

unknown

Returns

asserts m is Packument


assertRecordStringString()

function assertRecordStringString(o): void

Defined in: index.ts:363

Parameters

o

unknown

Returns

void


assertRecordStringT()

function assertRecordStringT<T>(
o,
check,
wanted,
): asserts o is Record<string, T>

Defined in: index.ts:381

Type Parameters

T

Parameters

o

unknown

check

(o) => o is T

wanted

string

Returns

asserts o is Record<string, T>


isError()

function isError(er): er is Error

Defined in: index.ts:334

Check if a value is an error.

Parameters

er

unknown

Returns

er is Error


isErrorWithCause()

function isErrorWithCause(er): er is Error & { cause: unknown }

Defined in: index.ts:340

Check if an error has a cause property.

Parameters

er

unknown

Returns

er is Error & { cause: unknown }


isIntegrity()

function isIntegrity(i): i is `sha512-${string}`

Defined in: index.ts:277

Parameters

i

unknown

Returns

i is `sha512-${string}`


isKeyID()

function isKeyID(k): k is `SHA256:${string}`

Defined in: index.ts:301

Parameters

k

unknown

Returns

k is `SHA256:${string}`


isManifest()

function isManifest(m): m is Manifest

Defined in: index.ts:426

Parameters

m

unknown

Returns

m is Manifest


isManifestRegistry()

function isManifestRegistry(m): m is ManifestRegistry

Defined in: index.ts:439

Parameters

m

unknown

Returns

m is ManifestRegistry


isObject()

function isObject(v): v is Record<string, unknown>

Defined in: index.ts:347

Check if an unknown value is a plain object.

Parameters

v

unknown

Returns

v is Record<string, unknown>


isPackument()

function isPackument(p): p is Packument

Defined in: index.ts:492

Parameters

p

unknown

Returns

p is Packument


isPeerDependenciesMetaValue()

function isPeerDependenciesMetaValue(
o,
): o is PeerDependenciesMetaValue

Defined in: index.ts:415

Parameters

o

unknown

Returns

o is PeerDependenciesMetaValue


isRecordStringManifest()

function isRecordStringManifest(o): o is Record<string, Manifest>

Defined in: index.ts:399

Parameters

o

unknown

Returns

o is Record<string, Manifest>


isRecordStringString()

function isRecordStringString(o): o is Record<string, string>

Defined in: index.ts:358

Parameters

o

unknown

Returns

o is Record<string, string>


isRecordStringT()

function isRecordStringT<T>(o, check): o is Record<string, T>

Defined in: index.ts:372

Type Parameters

T

Parameters

o

unknown

check

(o) => o is T

Returns

o is Record<string, T>


maybeBoolean()

function maybeBoolean(o): o is boolean

Defined in: index.ts:412

Parameters

o

unknown

Returns

o is boolean


maybeDist()

function maybeDist(a): a is undefined | Dist

Defined in: index.ts:423

Parameters

a

unknown

Returns

a is undefined | Dist


maybePeerDependenciesMetaSet()

function maybePeerDependenciesMetaSet(
o,
): o is undefined | Record<string, PeerDependenciesMetaValue>

Defined in: index.ts:404

Parameters

o

unknown

Returns

o is undefined | Record<string, PeerDependenciesMetaValue>


maybeRecordStringString()

function maybeRecordStringString(
o,
): o is undefined | Record<string, string>

Defined in: index.ts:353

Parameters

o

unknown

Returns

o is undefined | Record<string, string>


maybeString()

function maybeString(a): a is undefined | string

Defined in: index.ts:420

Parameters

a

unknown

Returns

a is undefined | string


normalizeFunding()

function normalizeFunding(funding): undefined | NormalizedFunding

Defined in: index.ts:74

Normalize funding information to a consistent format.

Parameters

funding

unknown

Returns

undefined | NormalizedFunding


normalizeManifest()

function normalizeManifest(manifest): Manifest

Defined in: index.ts:457

Returns a Manifest with normalized data.

Parameters

manifest

Manifest

Returns

Manifest