How to use the byline.createStream function in byline

To help you get started, we’ve selected a few byline 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 sharedstreets / trip-simulator / index.js View on Github external
const through2 = require("through2");
const byline = require("byline");
const turf = require("@turf/turf");
const OSRM = require("osrm");
const random = require("random");
const moment = require("moment");

const osrm = new OSRM("./data/nyc.osrm");

const DRIFT = 0.01;
const PERIOD = 20;
var normal = random.normal();

var k = 0;

process.stdin.pipe(byline.createStream()).pipe(
  through2((chunk, enc, next) => {
    k++;
    if (k % 1000 === 0) console.error(k);
    var line = chunk.toString();

    if (line.length && k > 1) {
      // skip header or trailing endline
      var cell = line.split(",");

      var record = {
        timeA: moment(cell[1]),
        timeB: moment(cell[2]),
        ptA: [+cell[5], +cell[6]],
        ptB: [+cell[9], +cell[10]]
      };
github hashtagchris / node-awaitify-stream / manualTests / guessCard.js View on Github external
async function run() {
    let stream = fs.createReadStream('txt/millionsOfGuesses.txt');
    stream.setEncoding('utf8');

    // read the file stream a line at a time.
    let lineStream = byline.createStream(stream, { keepEmptyLines: false });

    // awaitable interface for reading the stream.
    let reader = aw.createReader(lineStream);

    // readline for prompting the user.
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });

    try {
        let line;
        while (null !== (line = await reader.readAsync())) {
            let guessedCard = await checkGuess(rl, line);

            if (guessedCard) {
github ezpaarse-project / ezpaarse / platforms / cairn / parser.js View on Github external
exports.parserExecute = function (urls) {
  if (urls && Array.isArray(urls)) {
    var results = [];
    for (var i = 0, l = urls.length; i < l; i++) {
      results.push(parseUrl(urls[i]));
    }
    return results;
  } else {
    var stdin = process.stdin;
    var stdout = process.stdout;
    var stream = byline.createStream(stdin);

    stream.on('end', function () {
      process.exit(0);
    });

    stream.on('close', function () {
      process.exit(0);
    });

    stream.on('data', function (line) {
      stdout.write(JSON.stringify(parseUrl(line.toString())) + '\n');
    });
  }
};
github nodezoo / nodezoo-workshop / lib / nodezoo.js View on Github external
.on('root',function(){
        var rs = fs.createReadStream(npmfile); 
        rs.setEncoding('ascii')
        
        var linestream = byline.createStream()

        linestream.on('data', function(line){

	  try {
            try {
	      var data = JSON.parse( cutcomma(line) )
            }
            catch(e){
              console.log(e)
              return
            }

	    var v = data.value

	    var doc = {
	      name:v.name,
github ezpaarse-project / ezpaarse / platforms / npg / parser.js View on Github external
exports.parserExecute = function (urls) {

  if (urls && Array.isArray(urls)) {
    var results = [];
    for (var i = 0, l = urls.length; i < l; i++) {
      results.push(parseUrl(urls[i]));
    }
    return results;
  } else {
    var stdin = process.stdin;
    var stdout = process.stdout;
    var stream = byline.createStream(stdin);

    stream.on('end', function () {
      process.exit(0);
    });

    stream.on('close  ', function () {
      process.exit(0);
    });

    stream.on('data', function (line) {
      stdout.write(JSON.stringify(parseUrl(line.toString())) + '\n');
    });
  }
};
github ezpaarse-project / ezpaarse / platforms / dalloz / parser.js View on Github external
exports.parserExecute = function (urls) {

  if (urls && Array.isArray(urls)) {
    var results = [];
    for (var i = 0, l = urls.length; i < l; i++) {
      results.push(parseUrl(urls[i]));
    }
    return results;
  } else {
    var stdin = process.stdin;
    var stdout = process.stdout;
    var stream = byline.createStream(stdin);

    stream.on('end', function () {
      process.exit(0);
    });

    stream.on('close  ', function () {
      process.exit(0);
    });

    stream.on('data', function (line) {
      stdout.write(JSON.stringify(parseUrl(line.toString())) + '\n');
    });
  }
};
github ezpaarse-project / ezpaarse / platforms / edp / parser.js View on Github external
exports.parserExecute = function (urls) {

  if (urls && Array.isArray(urls)) {
    var results = [];
    for (var i = 0, l = urls.length; i < l; i++) {
      results.push(parseUrl(urls[i]));
    }
    return results;
  } else {
    var stdin = process.stdin;
    var stdout = process.stdout;
    var stream = byline.createStream(stdin);

    stream.on('end', function () {
      process.exit(0);
    });

    stream.on('close  ', function () {
      process.exit(0);
    });

    stream.on('data', function (line) {
      stdout.write(JSON.stringify(parseUrl(line.toString())) + '\n');
    });
  }
};
github ezpaarse-project / ezpaarse / platforms / bmc / parser.js View on Github external
exports.parserExecute = function (urls) {

  if (urls && Array.isArray(urls)) {
    var results = [];
    for (var i = 0, l = urls.length; i < l; i++) {
      results.push(parseUrl(urls[i]));
    }
    return results;
  } else {
    var stdin = process.stdin;
    var stdout = process.stdout;
    var stream = byline.createStream(stdin);

    stream.on('end', function () {
      process.exit(0);
    });

    stream.on('close  ', function () {
      process.exit(0);
    });

    stream.on('data', function (line) {
      stdout.write(JSON.stringify(parseUrl(line.toString())) + '\n');
    });
  }
};
github ezpaarse-project / ezpaarse / platforms / lamyline / parser.js View on Github external
exports.parserExecute = function (urls) {

  if (urls && Array.isArray(urls)) {
    var results = [];
    for (var i = 0, l = urls.length; i < l; i++) {
      results.push(parseUrl(urls[i]));
    }
    return results;
  } else {
    var stdin = process.stdin;
    var stdout = process.stdout;
    var stream = byline.createStream(stdin);

    stream.on('end', function () {
      process.exit(0);
    });

    stream.on('close  ', function () {
      process.exit(0);
    });

    stream.on('data', function (line) {
      stdout.write(JSON.stringify(parseUrl(line.toString())) + '\n');
    });
  }
};
github presidential-innovation-fellows / clinical-trials-search / import / transform / transform_trials.js View on Github external
_loadThesaurus(callback) {
    logger.info("Loading the NCI Thesaurus...");
    let header = [
      "code", "concept_name", "parents", "synonyms",
      "definition", "display_name", "semantic_types"
    ];
    let delimiter = "\t";
    let exclude = [
      "definition", "semantic_types"
    ]
    this.thesaurus = [];

    let rs = fs.createReadStream(path.join(__dirname, THESAURUS_FILEPATH));
    let ls = byline.createStream();
    let cs = new CsvStream({header, delimiter, exclude});

    rs.on("error", (err) => { logger.error(err); })
      .pipe(ls)
      .on("error", (err) => { logger.error(err); })
      .pipe(cs)
      .on("error", (err) => { logger.error(err); })
      .on("data", (jsonRow) => {
        this.thesaurus.push(jsonRow);
      })
      .on("finish", () => {
        logger.info(`Loaded ${this.thesaurus.length} terms from the NCI Thesaurus.`);
        return callback();
      });
  }

byline

simple line-by-line stream reader

MIT
Latest version published 8 years ago

Package Health Score

67 / 100
Full package analysis