How to use the mississippi.through.obj function in mississippi

To help you get started, we’ve selected a few mississippi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anandthakker / doiuse.com / lib / limit.js View on Github external
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
github npm / pacote / lib / registry / request.js View on Github external
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.'
        )
github anandthakker / doiuse.com / lib / prune.js View on Github external
module.exports = function () { return through.obj(pruneFeatureUsage) }
github anandthakker / doiuse.com / lib / unique.js View on Github external
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
}
github anandthakker / doiuse.com / lib / unique.js View on Github external
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
}

mississippi

a collection of useful streams

BSD-2-Clause
Latest version published 5 years ago

Package Health Score

74 / 100
Full package analysis

Similar packages