Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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}))
}
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() }
export function createOsxSecurityParsingStream(): NodeJS.ReadWriteStream {
return new Pumpify.obj(split(), new OsxSecurityParsingStream());
}
}
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')
})
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)) {
function combine (streams) {
if (streams.length === 1) return streams[0]
return pumpify.obj(streams)
}
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()
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);
}),
]);
() =>
new pumpify.obj(
multistream.obj(components),
makeCompanionManifest({
projectConfig,
buildId,
hasSettings: !!settings,
}),
zip('companion.zip'),
gulpSetProperty({
componentBundle: { type: 'companion' },
}),
sourceMaps.emitter,
),
);
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)
}