Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const stream = require('stream')
const cache = new Map() // you might wanna use an lru here
function createCacheStream (url) {
const buf = []
return stream.Transform({
transform: function (data, enc, cb) {
buffer.push(data)
cb(null, data)
},
flush: function (cb) {
cache.set(url, Buffer.concat(buf))
cb()
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.