How to use the pumpify function in pumpify

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}))
}

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