Skip to content
This repository has been archived by the owner on Jun 12, 2022. It is now read-only.

Commit

Permalink
fix(logging): remove console.log calls
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Mar 30, 2017
1 parent a0f6ece commit a1d0a47
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 11 deletions.
4 changes: 0 additions & 4 deletions cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ module.exports = class Cache {
bufSize += chunk.length
cb()
}, done => {
console.log('writing to cache', this._cachePath)
cacache.put(
this._cachePath,
cacheKey(req),
Expand All @@ -145,13 +144,10 @@ module.exports = class Cache {
newBody.once('error', err => oldBody.emit('error', err))
cacheStream.once('error', err => newBody.emit('error', err))
pipe(oldBody, to((chunk, enc, cb) => {
console.log('writing to cacheStream')
cacheStream.write(chunk, enc, () => {
console.log('writing to newBody')
newBody.write(chunk, enc, cb)
})
}, done => {
console.log('wooo')
cacheStream.end(() => newBody.end(done))
}), err => newBody.emit('error', err))
return response
Expand Down
7 changes: 0 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ function cachingFetch (uri, opts) {
}
return fetch.Promise.resolve(res).then(res => {
if (res && opts.cache === 'default' && !isStale(res)) {
console.log(uri, 'local cache data not stale. Skipping 304 check.')
return res
} else if (res && (opts.cache === 'default' || opts.cache === 'no-cache')) {
return condFetch(uri, res, opts)
} else if (!res && opts.cache === 'only-if-cached') {
throw new Error(`request to ${uri} failed: cache mode is 'only-if-cached' but no cached response available.`)
} else {
// Missing cache entry, stale default, reload, no-store
console.log(uri, 'no cache mode. Plain remote req')
return remoteFetch(uri, opts)
}
})
Expand Down Expand Up @@ -83,7 +81,6 @@ function heuristicFreshness (res) {
}

function condFetch (uri, res, opts) {
console.log(uri, 'conditional request')
const newHeaders = {}
Object.keys(opts.headers || {}).forEach(k => {
newHeaders[k] = opts.headers[k]
Expand All @@ -103,10 +100,8 @@ function condFetch (uri, res, opts) {
opts.headers = newHeaders
return remoteFetch(uri, opts).then(condRes => {
if (condRes.status === 304) {
console.log(uri, 'got 304. Using old request body')
condRes.body = res.body
} else {
console.log(uri, 'condition did not match. Using new request')
}
return condRes
})
Expand Down Expand Up @@ -144,10 +139,8 @@ function remoteFetch (uri, opts) {
})
return fetch(req).then(res => {
if (!opts.cachePath || opts.cache === 'no-store' || res.status > 299) {
console.log(uri, 'not saving to cache')
return res
} else {
console.log(uri, 'saving to cache')
return new Cache(opts.cachePath, opts).put(req, res)
}
})
Expand Down

0 comments on commit a1d0a47

Please sign in to comment.