Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
opts.limit = opts.limit || 100
var readFn = opts.sort === 'desc' ? fsReverse : fs.createReadStream
var readStream = readFn(getLogPath(opts.logFile || 0), {encoding: 'utf8'})
const nosplit = (readFn === fsReverse) // fs-reverse splits for us
pump(
readPipeline(readStream, opts, nosplit),
concat({encoding: 'object'}, res => resolve(/** @type any */(res))),
reject
)
})
}
})
}
let parseError = false;
try {
if (file.isBuffer()) {
let args = {
buf: file.contents,
name: path.basename(file.relative),
path: file.relative,
}
parseFile(args)
}
if (file.isStream()) {
file.pipe(concat(buf => {
parseFile({ buf })
}))
}
} catch (error) {
parseError = true;
cb(error);
}
// Pass-through.
if (!parseError) {
cb(null, file)
}
}
}
if (route.staticResponse) {
emitReceived()
sendStaticResponse(request.res, route.staticResponse, request.onResponse!)
return // don't call cb since we've satisfied the response here
}
// if we already have a body, just emit
if (frame.req.body) {
return emitReceived()
}
// else, buffer the body
request.req.pipe(concatStream((reqBody) => {
frame.req.body = reqBody.toString()
emitReceived()
}))
}
return new Promise((resolve, reject) => {
let rs = debugLogFile.createReadStream()
rs
.pipe(split())
.pipe(through({encoding: 'utf8', decodeStrings: false}, (data, _, cb) => {
if (data && data.startsWith(key)) {
return cb(null, data.slice(key.length) + '\n')
}
cb()
}))
.pipe(concat({encoding: 'string'}, resolve))
rs.on('error', reject)
})
}
return new Promise((resolve, reject) => {
var stream = checkoutFS.history({live: false, start, end})
stream.pipe(concat({encoding: 'object'}, values => {
values = values.map(massageHistoryObj)
if (reverse) values.reverse()
resolve(values)
}))
stream.on('error', reject)
})
})
var request = transport.request(requestParams, (response) => {
if (response.statusCode !== 200) {
return parseError(response, cb)
}
response.pipe(Concat(xml => {
var parsedXml = ParseXml(xml.toString()),
uploadId = null
parsedXml.root.children.forEach(element => {
if (element.name === 'UploadId') {
uploadId = element.content
}
})
if (uploadId) {
return cb(null, uploadId)
}
cb('unable to get upload id')
}))
})
request.end()
return new Promise(resolve => {
formData.pipe(concat({ encoding: 'buffer' }, data => resolve({ data })));
});
}
}, (res) => {
if (res.statusCode === 204) {
debug('Ping succeeded')
resolve()
} else {
res.setEncoding('utf8')
res.pipe(concat(body => debug('Ping failed', res.statusCode, body)))
reject()
}
})
req.on('error', err => {
return new Promise((resolve, reject) => {
const readStream = fs.createReadStream(`${folder}${sep}vid${vidExtension}`)
readStream.on('error', reject)
readStream.pipe(concat(resolve)).on('error', reject)
})
}
return new Promise(resolve => {
formData.pipe(concat({ encoding: 'buffer' }, data => resolve({ data })));
});
}