Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// old body to bring in the data.
const newBody = new MinipassPipeline(new MinipassFlush({
flush () {
return cacheWritePromise
}
}))
let cacheWriteResolve, cacheWriteReject
const cacheWritePromise = new Promise((resolve, reject) => {
cacheWriteResolve = resolve
cacheWriteReject = reject
})
const cachePath = this._path
if (fitInMemory) {
const collecter = new MinipassCollect.PassThrough()
collecter.on('collect', data => {
cacache.put(
cachePath,
ckey,
data,
cacheOpts
).then(cacheWriteResolve, cacheWriteReject)
})
newBody.unshift(collecter)
} else {
const tee = new Minipass()
const cacheStream = cacache.put.stream(
cachePath,
ckey,
cacheOpts
)