@vltpkg/registry-client/cache-entry
Classes
CacheEntry
Defined in: cache-entry.ts:75
Constructors
new CacheEntry()
new CacheEntry( statusCode, headers, __namedParameters): CacheEntry
Defined in: cache-entry.ts:85
Parameters
statusCode
number
headers
Buffer
[]
__namedParameters
CacheEntryOptions
= {}
Returns
Accessors
body
Get Signature
get body(): Buffer | Record<string, any>
Defined in: cache-entry.ts:250
Returns
Buffer
| Record
<string
, any
>
headers
Get Signature
get headers(): Buffer[]
Defined in: cache-entry.ts:165
Returns
Buffer
[]
integrity
Get Signature
get integrity(): undefined | `sha512-${string}`
Defined in: cache-entry.ts:218
Returns
undefined
| `sha512-${string}`
Set Signature
set integrity(i): void
Defined in: cache-entry.ts:212
Parameters
i
undefined
| `sha512-${string}`
Returns
void
integrityActual
Get Signature
get integrityActual(): `sha512-${string}`
Defined in: cache-entry.ts:198
Returns
`sha512-${string}`
Set Signature
set integrityActual(i): void
Defined in: cache-entry.ts:207
Parameters
i
`sha512-${string}`
Returns
void
isGzip
Get Signature
get isGzip(): boolean
Defined in: cache-entry.ts:270
Returns
boolean
isJSON
Get Signature
get isJSON(): boolean
Defined in: cache-entry.ts:255
Returns
boolean
statusCode
Get Signature
get statusCode(): number
Defined in: cache-entry.ts:162
Returns
number
valid
Get Signature
get valid(): boolean
Defined in: cache-entry.ts:133
true
if the entry represents a cached response that is still valid
to use.
Returns
boolean
Methods
[kCustomInspect]()
kCustomInspect: string
Defined in: cache-entry.ts:106
Parameters
depth
number
options
InspectOptions
Returns
string
addBody()
addBody(b): void
Defined in: cache-entry.ts:157
Parameters
b
Buffer
Returns
void
buffer()
buffer(): Buffer
Defined in: cache-entry.ts:239
Return the body of the entry as a Buffer
Returns
Buffer
checkIntegrity()
checkIntegrity(context): this is CacheEntry & { integrity: `sha512-${string}` }
Defined in: cache-entry.ts:182
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.
This method will throw if the integrity values do not match.
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 true if anything was actually verified.
Parameters
context
ErrorCauseObject
= {}
Returns
this is CacheEntry & { integrity: `sha512-${string}` }
encode()
encode(): Buffer
Defined in: cache-entry.ts:400
Encode the entry as a single Buffer for writing to the cache
Returns
Buffer
getHeader()
getHeader(h): undefined | Buffer
Defined in: cache-entry.ts:225
Give it a key, and it’ll return the buffer of that header value
Parameters
h
string
Returns
undefined
| Buffer
json()
json(): JSONObj
Defined in: cache-entry.ts:322
Parse the entry body as JSON and return the result
Returns
setHeader()
setHeader(h, value): void
Defined in: cache-entry.ts:232
Set a header to a specific value
Parameters
h
string
value
string
| Buffer
Returns
void
text()
text(): string
Defined in: cache-entry.ts:314
Return the body of the entry as utf8 text Automatically unzips if the content is gzip encoded
Returns
string
unzip()
unzip(): boolean
Defined in: cache-entry.ts:291
Un-gzip encode the body. Returns true if it was previously gzip (so something was done), otherwise returns false.
Returns
boolean
decode()
static decode(buffer): CacheEntry
Defined in: cache-entry.ts:334
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
isGzipEntry()
static isGzipEntry(buffer): boolean
Defined in: cache-entry.ts:388
Parameters
buffer
Buffer
Returns
boolean
Type Aliases
CacheEntryOptions
type CacheEntryOptions = object
Defined in: cache-entry.ts:59
Type declaration
integrity?
optional integrity: Integrity;
The expected integrity value for this response body
trustIntegrity?
optional trustIntegrity: boolean;
Whether to trust the integrity, or calculate the actual value.
This indicates that we just accept whatever the integrity is as the actual integrity for saving back to the cache, because it’s coming directly from the registry that we fetched a packument from, and is an initial gzipped artifact request.
JSONObj
type JSONObj = Record<string, JSONField>
Defined in: cache-entry.ts:32