Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var server = http.createServer(function (req, res) {
var ip = req.headers['x-forwarded-for'] ||
req.connection.remoteAddress ||
req.socket.remoteAddress ||
req.connection.socket.remoteAddress
// POST /
// arguments (either query string or POST body) should have either `url` xor
// `css` property, and optional `browsers`.
// response is {args: {given args}, usages: [usages of queried features], count:{feature:count}}
if (req.method !== 'POST') {
console.log([Date.now(), req.method, req.url, ip].join('\t'))
}
if (req.method === 'POST') {
pipe(
req,
limit(1e6, function () { req.connection.destroy() }),
concat(function (args) {
console.log([Date.now(), req.method, req.url, ip, args.length + ' B'].join('\t'))
try {
args = JSON.parse(args)
cssFeatures(args, res)
} catch (e) {
debug('Error parsing request ', e.toString(), args)
res.statusCode = 400
res.end(JSON.stringify({
error: e.toString(),
statusCode: 400
}))
}
var serialiedTx = '0x'+tx.serialize().toString('hex')
cb(null, serialiedTx)
},
// msg signing
// approveMessage: addUnconfirmedMsg,
// signMessage: idStore.signMessage.bind(idStore),
})
provider.on('block', function(block){
console.log('BLOCK CHANGED:', '#'+block.number.toString('hex'), '0x'+block.hash.toString('hex'))
})
var connectionStream = new ParentStream()
// setup connectionStream multiplexing
var multiStream = ObjectMultiplex()
Streams.pipe(connectionStream, multiStream, connectionStream, function(err){
console.warn('MetamaskIframe - lost connection to Dapp')
if (err) throw err
})
var providerStream = multiStream.createStream('provider')
handleRequestsFromStream(providerStream, provider, logger)
function logger(err, request, response){
if (err) return console.error(err.stack)
if (!request.isMetamaskInternal) {
console.log('MetaMaskIframe - RPC complete:', request, '->', response)
if (response.error) console.error('Error in RPC response:\n'+response.error.message)
}
}
}
// By destroying `unzipped`, this *should* stop `tar-stream`
// from continuing to waste resources on tarball parsing.
unzipped.unpipe()
cb(null, shrinkwrap)
})
} else {
// Not a shrinkwrap. Autodrain this entry, and move on to the next.
fileStream.resume()
next()
}
})
// Any other streams that `pkgStream` is being piped to should
// remain unaffected by this, although there might be confusion
// around backpressure issues.
pipe(pkgStream, unzipped, function (err) {
// If we already successfully emitted a shrinkwrap,
// we literally don't care about any errors.
// Issues with `pkgStream` can be handled elsewhere if needed.
if (!shrinkwrap) { cb(err) }
})
}
it('should compile a pug template with an extends', function(done) {
function assert(files) {
expect(files.length).toEqual(1);
const newFile = files[0];
expect(newFile).toMatchObject({
contents: Buffer.from('<div><h1>Hello World</h1></div>'),
});
}
pipe([
from.obj([getFixture('extends.pug')]),
task(),
concat(assert),
], done);
});
});
return new Bluebird((resolve, reject) => {
pipe(
createReadStream(source),
createWriteStream(destination),
function (err) {
if (err) return reject(err)
log.verbose('flac.copy', 'copied', source, 'to', destination)
resolve()
}
)
})
}
return new Bluebird((resolve, reject) => {
pipe(
createReadStream(track.file.path),
gauge.newStream('copying: ' + track.safeName(), track.file.stats.size),
createWriteStream(destination),
function (err) {
if (err) return reject(err)
gauge.verbose('copyTrack', 'copied', track.file.path, 'to', destination)
resolve()
}
)
})
}
return fromCallback(cb => miss.pipe(inputStream, parser, outputStream, cb))
}
function readFile(name, cb){
cb = once(cb);
var writeStream = miss.concat(function(data){
cb(null, data.toString());
});
miss.pipe(options.blobstore.createReadStream(name), writeStream, function(err) {
if (err) return cb(err);
});
}
new Promise((resolve, reject) => {
const outputPath = path.join(tempy.directory(), 'sanity-import')
debug('Importing from stream')
let isTarStream = false
let jsonDocuments
const uncompressStream = miss.pipeline(gunzipMaybe(), untarMaybe())
miss.pipe(
stream,
uncompressStream,
err => {
if (err) {
reject(err)
return
}
if (isTarStream) {
findAndImport()
} else {
resolve(importers.fromArray(jsonDocuments, options))
}
}
)
return new Promise((resolve, reject) =>
miss.pipe(stream, hasher, fse.createWriteStream(filePath), err => {
if (err) {
reject(err)
return
}
resolve({
size,
sha1: sha1.digest('hex'),
md5: md5.digest('hex')
})
})
)