How to use the cacache.get.byDigest function in cacache

To help you get started, we’ve selected a few cacache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github npm / tink / lib / pkglock.js View on Github external
async function read ({ cache, hash, pkg, resolvedPath, isFile }) {
  if (!cache || !hash || !isFile) {
    throw new Error('read() requires a fully-resolved pkgmap file address')
  }
  try {
    return ccGet.byDigest(cache, hash, { memoize: true })
  } catch (err) {
    const newResolved = await fetchPackage(cache, pkg, hash)
    return ccGet.byDigest(newResolved.cache, newResolved.hash, { memoize: true })
  }
}
github npm / tink / lib / pkglock.js View on Github external
async function read ({ cache, hash, pkg, resolvedPath, isFile }) {
  if (!cache || !hash || !isFile) {
    throw new Error('read() requires a fully-resolved pkgmap file address')
  }
  try {
    return ccGet.byDigest(cache, hash, { memoize: true })
  } catch (err) {
    const newResolved = await fetchPackage(cache, pkg, hash)
    return ccGet.byDigest(newResolved.cache, newResolved.hash, { memoize: true })
  }
}