How to use pumpify - 10 common examples

To help you get started, we’ve selected a few pumpify 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 sanity-io / sanity / packages / @sanity / core / src / actions / dataset / import / importDocumentsToDataset.js View on Github external
function importDocumentsToDataset(options, context, promise) {
  const {resolve, reject} = promise
  const {inputStream, targetDataset, client, operation} = options

  // Create stream that batches documents into transactions
  const mutationStream = batchedMutationStream({
    client,
    mutator: (transaction, doc) => transaction[operation](doc),
    dataset: targetDataset,
    progress: options.progress,
    batchSize: options.batchSize
  })

  const startTime = Date.now()
  const stream = pumpify(
    // Read from input stream
    inputStream,
    // Split on each newline character and parse line as JSON
    getJsonStreamer(),
    // Make strong references weak, create reference maps so we can transform them back
    getReferenceWeakener(options),
    // Transform and upload assets
    getBatchedAssetImporter(options),
    // Batch into a transaction of mutations
    mutationStream
  )

  stream.once('error', reject)
  mutationStream.on('complete', () => resolve({timeSpent: Date.now() - startTime}))
}
github bionode / bionode-ncbi / lib / bionode-ncbi.js View on Github external
function parseResult (resFmt) {
  var lastStream = (resFmt === 'fasta') ? fasta.obj : through.obj

  var stream = pumpify.obj(
      requestStream('true'),
      preProcess(),
      lastStream()
  )

  return stream

  function preProcess () {
    var stream = through.obj(transform)
    return stream

    function transform (chunk, enc, cb) {
      var self = this
      if (resFmt === 'xml') {
        xml2js(chunk.body, function (err, data) {
          if (err) { self.emit('error', err); return cb() }
github microsoft / appcenter-cli / src / util / token-store / osx / osx-keychain-parser.ts View on Github external
export function createOsxSecurityParsingStream(): NodeJS.ReadWriteStream {
  return new Pumpify.obj(split(), new OsxSecurityParsingStream());
}
github maxogden / dat-core / lib / replicate.js View on Github external
}

    hasOperation(commit.operations, function (err, exists) {
      if (err) return cb(err)
      if (exists) return cb(null, node)

      var op = plex.createStream('operation/' + commit.operations)

      collect(op, function (err, batch) {
        if (err) return plex.destroy(err)
        onbatch(batch)
      })
    })
  })

  var graph = self._index.log.replicate(xtend(opts, { finalize: finalize, process: pumpify.obj(buf, queue) }))
  var graphOut = plex.createStream('graph')
  var graphIn = plex.receiveStream('graph')

  pump(graphIn, graph, graphOut)

  graph.on('error', function (err) {
    plex.destroy(err)
  })

  graph.on('metadata', function (value) {
    plex.emit('metadata', value)
  })

  graph.on('push', function () {
    plex.emit('push')
  })
github jdesboeufs / geojson2shp / lib / convert.js View on Github external
function createInputStream(input) {
  if (typeof input === 'string') {
    return pumpify.obj(
      createReadStream(input),
      createGunzip(),
      parse()
    )
  }
  if (isStream(input)) {
    return pumpify.obj(
      input,
      createGunzip(),
      parse()
    )
  }
  if (isFeatureCollection(input)) {
    return arrayToStream(input.features)
  }
  if (isFeatureArray(input)) {
github okdistribute / parse-input-stream / index.js View on Github external
function combine (streams) {
  if (streams.length === 1) return streams[0]
  return pumpify.obj(streams)
}
github kemitchell / lamos.js / tokenizer.js View on Github external
module.exports = function () {
  var state = core.tokenizerState()
  var lineNumber = 0
  return pumpify.obj(
    split2(),
    through2.obj(
      function (line, _, done) {
        var push = this.push.bind(this)
        line = line.toString()
        lineNumber++
        try {
          core.tokenizeLine(state, line, lineNumber, push)
          done()
        } catch (error) {
          done(error)
        }
      },
      function (done) {
        core.flushTokenizer(state, this.push.bind(this))
        done()
github googleapis / nodejs-bigtable / src / table.ts View on Github external
reqOpts.rowsLimit = rowsLimit - rowsRead;
      }

      const requestStream = this.bigtable.request({
        client: 'BigtableClient',
        method: 'readRows',
        reqOpts,
        gaxOpts: options.gaxOptions,
        retryOpts,
      });

      activeRequestStream = requestStream;

      requestStream.on('request', () => numRequestsMade++);

      const rowStream = pumpify.obj([
        requestStream,
        chunkTransformer,
        through.obj((rowData, enc, next) => {
          if (
            chunkTransformer._destroyed ||
            (userStream as any)._writableState.ended
          ) {
            return next();
          }
          numRequestsMade = 0;
          rowsRead++;
          const row = this.row(rowData.key);
          row.data = rowData.data;
          next(null, row);
        }),
      ]);
github Fitbit / fitbit-sdk-toolchain / src / index.ts View on Github external
() =>
      new pumpify.obj(
        multistream.obj(components),
        makeCompanionManifest({
          projectConfig,
          buildId,
          hasSettings: !!settings,
        }),
        zip('companion.zip'),
        gulpSetProperty({
          componentBundle: { type: 'companion' },
        }),
        sourceMaps.emitter,
      ),
  );
github digidem / kappa-osm / index.js View on Github external
var fetch = through.obj(function (row, _, next) {
    self._getByVersion(row.version, function (err, elm) {
      if (err) return next(err)
      var res = Object.assign(elm, {
        version: row.version,
        deviceId: versionToDeviceId(row.version),
        id: row.id
      })
      next(null, res)
    })
  })

  var ropts = {}
  if (opts.limit) ropts.limit = opts.limit

  return pumpify.obj(this.core.api.types.createReadStream(type, ropts), fetch)
}

pumpify

Combine an array of streams into a single duplex stream using pump and duplexify

MIT
Latest version published 5 years ago

Package Health Score

67 / 100
Full package analysis

Popular pumpify functions