Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function limit (size, onLimit) {
var soFar = 0
size = through.obj()
var lim = through(function (chunk, enc, next) {
soFar += chunk.length
if (soFar > size && !(size = onLimit(soFar, chunk))) {
next(new Error('Limit reached.'))
} else {
next(null, chunk)
}
},
function end (next) {
this.push(null)
size.end('' + soFar)
lim.ended = true
next()
})
lim.size = size
function getStream (uri, registry, opts) {
var key = cache.key('registry-request', uri)
var stream = opts.json ? through.obj() : through()
if (!opts.cache) {
opts.log.silly('registry.get', 'no cache option. skipping cache fetch')
switchToRegistry(null, null)
} else {
opts.log.silly('registry.get', 'trying to grab from cache')
var cs = cache.get.stream(opts.cache, key, opts)
cs.once('data', function () {
opts.log.silly('registry.get', 'got data for', key, 'from cache.')
})
cs.on('metadata', function (meta) {
if (isStale(meta, opts)) {
opts.log.silly(
'registry.get',
'cache data for', key, 'stale. Checking registry.'
)
module.exports = function () { return through.obj(pruneFeatureUsage) }
module.exports = function unique () {
var used = {}
var uniq = {
counts: through.obj(),
features: through.obj(function (usage, enc, next) {
if (usage.feature && used[usage.feature]++) return next()
if (usage.feature) used[usage.feature] = 1
next(null, usage)
},
function end (next) {
uniq.counts.end(JSON.stringify(used))
uniq.ended = true
this.push(null)
next()
})
}
return uniq
}
module.exports = function unique () {
var used = {}
var uniq = {
counts: through.obj(),
features: through.obj(function (usage, enc, next) {
if (usage.feature && used[usage.feature]++) return next()
if (usage.feature) used[usage.feature] = 1
next(null, usage)
},
function end (next) {
uniq.counts.end(JSON.stringify(used))
uniq.ended = true
this.push(null)
next()
})
}
return uniq
}