How to use the mississippi.concat 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
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
          }))
        }
      }),
      function (err) {
        if (err) { console.error(err) }
github whxaxes / blog / scripts / pack.js View on Github external
console.info('packing...');
console.time('packing cost');
miss.pipe(
  [
    vinyl
      .src([
        '**/*',
        '!node_modules/**/*',
        '!coverage/**/*',
        '!run/**/*',
        '!logs/**/*',
        '!.cache/**/*',
        '!.vscode/**/*',
      ])
      .pipe(vinyl.dest(packDir)),
    miss.concat(assert),
  ],
  () => {
    shell.cd(packDir);
    shell.exec('zip -qr ./pack.zip ./*');
    shell.exec(`scp ./pack.zip ${sshConfig.username}@${sshConfig.host}:${sshConfig.distDir}`);
    shell.exec('rm -rf ' + packDir);
    console.info('packing success');
    console.timeEnd('packing cost');
    sshToRemote();
  }
);

// get clean files
function getCleanFiles() {
  const files = [
    './app/controller',
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 / utils-transcode.js View on Github external
var verifier = spawn(
          mp3val,
          [ path ],
          {}
        )

        pipe(verifier.stdout, concat({ encoding: 'string' }, function (output) {
          t.notMatch(output, /WARNING/m, 'no warnings from mp3val')
          t.match(
            output,
            /INFO.+166 MPEG frames \(MPEG 1 Layer III\), \+ID3v2, Xing header/m,
            'found expected stream content'
          )
        }))

        pipe(verifier.stderr, concat({ encoding: 'string' }, function (output) {
          t.notOk(output, 'no error output from mp3val')
        }))

        verifier.on('error', reject)
        verifier.on('close', function (code) {
          t.equal(code, 0, 'exited without issue')
          resolve()
        })
      })
    })
github othiym23 / packard / test / lib / flac.js View on Github external
return new Bluebird(function (resolve, reject) {
          log.silly('makeAlbum.setTags', tags.join('\n'))
          var tagger = spawn(
            metaflac,
            [
              '--import-tags-from=-',
              destination
            ],
            {}
          )

          pipe(tagger.stdout, concat({ encoding: 'string' }, function (output) {
            if (output.toString()) log.silly('makeAlbum.setTags', output)
          }))

          pipe(tagger.stderr, concat({ encoding: 'string' }, function (output) {
            if (output) return reject(new Error(output))
          }))

          tagger.on('error', reject)
          tagger.on('close', function (code) {
            if (code !== 0) {
              return reject(new Error('metaflac exited with error status of ' + code))
            }
            log.silly('makeAlbum.pipe', 'copied and tagged', destination)
            resolve(destination)
          })

          tagger.stdin.write(tags.join('\n') + '\n')
          tagger.stdin.end()
        })
      })
github anandkumarpatel / rest-fs / dockerDriver.js View on Github external
docker.execContainer(containerId, command, function (err, execStream) {
    var streamCleanser = createStreamCleanser()
    var response
    var concatStream = miss.concat(function (result) {
      response = result
    })
    miss.pipe(execStream, streamCleanser, buff2String(), concatStream, function (err) {
      console.log('executed', containerId, command, err, response)
      cb(err, response)
    })
  })
}
github sanity-io / sanity / packages / @sanity / import / src / importFromStream.js View on Github external
return peek({newline: false, maxBuffer: 300}, (data, swap) => {
        if (isTar(data)) {
          debug('Stream is a tarball, extracting to %s', outputPath)
          isTarStream = true
          return swap(null, tar.extract(outputPath))
        }

        debug('Stream is an ndjson file, streaming JSON')
        const jsonStreamer = getJsonStreamer()
        const concatter = miss.concat(resolveNdjsonStream)
        const ndjsonStream = miss.pipeline(jsonStreamer, concatter)
        ndjsonStream.on('error', err => {
          uncompressStream.emit('error', err)
          destroy([uncompressStream, jsonStreamer, concatter, ndjsonStream])
          reject(err)
        })
        return swap(null, ndjsonStream)
      })
    }
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 davglass / registry-static / lib / files.js View on Github external
function readJSONFile(name, callback) {
    callback = once(callback);
    miss.pipe(options.blobstore.createReadStream(name), miss.concat(function(data){
        try {
            callback(null, JSON.parse(data.toString()));
        } catch (error) {
            callback(error);
        }
    }), function(err){
        if (err) { callback(err); }
    });
}
github npm / cacache / lib / entry-index.js View on Github external
return new Promise((resolve, reject) => {
    lsStream(cache)
      .on('error', reject)
      .pipe(
        concat((entries) => {
          resolve(
            entries.reduce((acc, xs) => {
              acc[xs.key] = xs
              return acc
            }, {})
          )
        })
      )
  })
}