Skip to content

cache-entry | @vltpkg/registry-client

Classes

CacheEntry

Constructors

new CacheEntry()
new CacheEntry(
statusCode,
headers,
integrity?): CacheEntry
Parameters

statusCode: number

headers: Buffer[]

integrity?: `sha512-${string}`

Returns

CacheEntry

Defined in

cache-entry.ts:67

Accessors

body
get body(): Buffer | Record<string, any>
Returns

Buffer | Record<string, any>

Defined in

cache-entry.ts:194

headers
get headers(): Buffer[]
Returns

Buffer[]

Defined in

cache-entry.ts:138

integrity
get integrity(): undefined | `sha512-${string}`
Returns

undefined | `sha512-${string}`

Defined in

cache-entry.ts:162

integrityActual
get integrityActual(): `sha512-${string}`
Returns

`sha512-${string}`

Defined in

cache-entry.ts:155

isGzip
get isGzip(): boolean
Returns

boolean

Defined in

cache-entry.ts:216

isJSON
get isJSON(): boolean
Returns

boolean

Defined in

cache-entry.ts:199

statusCode
get statusCode(): number
Returns

number

Defined in

cache-entry.ts:135

valid
get valid(): boolean

true if the entry represents a cached response that is still valid to use.

Returns

boolean

Defined in

cache-entry.ts:106

Methods

[kCustomInspect]()
kCustomInspect: string
Parameters

depth: number

options: InspectOptions

Returns

string

Defined in

cache-entry.ts:87

addBody()
addBody(b): void
Parameters

b: Buffer

Returns

void

Defined in

cache-entry.ts:130

buffer()
buffer(): Buffer

Return the body of the entry as a Buffer

Returns

Buffer

Defined in

cache-entry.ts:183

checkIntegrity()
checkIntegrity(): boolean

check that the sri integrity string that was provided to the ctor matches the body that we actually received. This should only be called AFTER the entire body has been completely downloaded.

Note that this will usually not be true if the value is coming out of the cache, because the cache entries are un-gzipped in place. It should only be called for artifacts that come from an actual http response.

Returns

boolean

Defined in

cache-entry.ts:151

encode()
encode(): Buffer

Encode the entry as a single Buffer for writing to the cache

Returns

Buffer

Defined in

cache-entry.ts:327

getHeader()
getHeader(h): undefined | Buffer

Give it a key, and it’ll return the buffer of that header value

Parameters

h: string

Returns

undefined | Buffer

Defined in

cache-entry.ts:169

json()
json(): JSONObj

Parse the entry body as JSON and return the result

Returns

JSONObj

Defined in

cache-entry.ts:268

setHeader()
setHeader(h, value): void

Set a header to a specific value

Parameters

h: string

value: string | Buffer

Returns

void

Defined in

cache-entry.ts:176

text()
text(): string

Return the body of the entry as utf8 text Automatically unzips if the content is gzip encoded

Returns

string

Defined in

cache-entry.ts:260

unzip()
unzip(): boolean

Un-gzip encode the body. Returns true if it was previously gzip (so something was done), otherwise returns false.

Returns

boolean

Defined in

cache-entry.ts:237

decode()
static decode(buffer): CacheEntry

Pass the contents of a @vltpkg/cache.Cache object as a buffer, and this static method will decode it into a CacheEntry representing the cached response.

Parameters

buffer: Buffer

Returns

CacheEntry

Defined in

cache-entry.ts:289