Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 ccRead(cache, hash)
} catch (err) {
const newResolved = await repairPackage({ cache, hash, pkg, resolvedPath })
cache = newResolved.cache
hash = newResolved.hash
pkg = newResolved.pkg
return ccRead(cache, hash)
}
}
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 ccRead(cache, hash)
} catch (err) {
const newResolved = await repairPackage({ cache, hash, pkg, resolvedPath })
cache = newResolved.cache
hash = newResolved.hash
pkg = newResolved.pkg
return ccRead(cache, hash)
}
}