How to use the mississippi.pipe function in mississippi

To help you get started, we’ve selected a few mississippi 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 anandthakker / doiuse.com / index.js View on Github external
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
          }))
        }
github MetaMask / zero-client / frame.js View on Github external
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)
    }
  }

}
github npm / pacote / lib / util / extract-shrinkwrap.js View on Github external
// 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) }
  })
}
github gulp-community / gulp-pug / test / extends.js View on Github external
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);
  });
});
github othiym23 / packard / test / lib / flac.js View on Github external
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()
      }
    )
  })
}
github othiym23 / packard / src / command / pack.js View on Github external
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()
      }
    )
  })
}
github nodys / spreadstream / bin / spreadstream.js View on Github external
    return fromCallback(cb => miss.pipe(inputStream, parser, outputStream, cb))
  }
github davglass / registry-static / lib / index.js View on Github external
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);
    });
}
github sanity-io / sanity / packages / @sanity / import / src / importFromStream.js View on Github external
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))
        }
      }
    )
github sanity-io / sanity / packages / @sanity / export / src / AssetHandler.js View on Github external
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')
      })
    })
  )