cache-entry | @vltpkg/registry-client
Classes
CacheEntry
Constructors
new CacheEntry()
Parameters
• statusCode: number
• headers: Buffer
[]
• integrity?: `sha512-${string}`
Returns
Defined in
cache-entry.ts:67
Accessors
body
Returns
Buffer
| Record
<string
, any
>
Defined in
cache-entry.ts:194
headers
Returns
Buffer
[]
Defined in
cache-entry.ts:138
integrity
Returns
undefined
| `sha512-${string}`
Defined in
cache-entry.ts:162
integrityActual
Returns
`sha512-${string}`
Defined in
cache-entry.ts:155
isGzip
Returns
boolean
Defined in
cache-entry.ts:216
isJSON
Returns
boolean
Defined in
cache-entry.ts:199
statusCode
Returns
number
Defined in
cache-entry.ts:135
valid
true
if the entry represents a cached response that is still
valid to use.
Returns
boolean
Defined in
cache-entry.ts:106
Methods
[kCustomInspect]()
Parameters
• depth: number
• options: InspectOptions
Returns
string
Defined in
cache-entry.ts:87
addBody()
Parameters
• b: Buffer
Returns
void
Defined in
cache-entry.ts:130
buffer()
Return the body of the entry as a Buffer
Returns
Buffer
Defined in
cache-entry.ts:183
checkIntegrity()
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 the entry as a single Buffer for writing to the cache
Returns
Buffer
Defined in
cache-entry.ts:327
getHeader()
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()
Parse the entry body as JSON and return the result
Returns
JSONObj
Defined in
cache-entry.ts:268
setHeader()
Set a header to a specific value
Parameters
• h: string
• value: string
| Buffer
Returns
void
Defined in
cache-entry.ts:176
text()
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()
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()
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
Defined in
cache-entry.ts:289