How to use line-reader - 10 common examples

To help you get started, we’ve selected a few line-reader 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 FrankBowers24 / d3-bayarea / data / getRent.js View on Github external
function getRentData(filename) {
  var zip;
  var inRentData = false;
  var buffer = "";
  var index = -1;
  var values = [];
  lineReader.eachLine(filename, function(line, last) {

    if (line.match(/Average Rental Rates in Zip Code/)) {
      zip = line.match(/[0-9]{5}/g)[0];
      // console.log('file: ', filename, 'zip: ', zip);
      inRentData = true;
    }
    if (inRentData) {
      if (line.match(/<\/p/)) {
        inRentData = false;
        for (var i = 0; i < aptRefs.length; i++) {
          index = buffer.search(new RegExp(aptRefs[i], 'i'));
          if (index >= 0) {
            values[i] = +buffer.slice(index).match(/\d{0,1},[0-9]{3}/)[0].replace(',', '');
          }
        }
      } else {
github scr1p7ed / mac-lookup / index.js View on Github external
var process = function(db) {

    lineReader.eachLine(options.txt, function(line, last) {

      line = line.trimLeft().trimRight();
      if (line.length < 15) { return; }


      // Get OUI
      var oui = line.substr(0,8).split('-').join('');
      if ( (oui) && (oui.length !== 6) ) { return; }


      // Get Name
      var name;
      line = line.substr(9).trimLeft();
      if (line.substr(0,5) === '(hex)') { name = line.substr(6).trimLeft(); }
      if (name === undefined)           { return; }
      if (name.length < 1)              { return; }
github ahkimkoo / neocrawler / proxyCollector / proxyCrawler.js View on Github external
proxyCrawler.prototype.addLinks = function(){
	console.log('addLinks');

	// delete old hosts
	client.del(PROXYS, function(err){
		if(err){
			console.log('ERROR :', err);
		} 	
	});	
	
	// add seeds 
	lineReader.eachLine(__dirname + '/hosts.txt', function(line, last) {
		//console.log(line);
		client.sadd(SEEDS, line, function(err){
				   if(err){
					   console.log();
				   }else {
					   console.log("Add link in addLinks: ",line);
				   }
		});	

		if(last){
			console.log('process :');
		}		
	});	
}
github lumigo-io / lumigo-CLI / src / commands / send-to-sns.js View on Github external
return new Promise(resolve => {
		lineReader.eachLine(filePath, function(line, last, cb) {
			if (_.isEmpty(line)) {
				cb();
			} else if (last) {
				add(line, true);
				queue.onEmpty().then(() => {
					cb();
					resolve();
				});
			} else if (processedCount % 100 === 0) {
				// to avoid overloading the queue and run of memory,
				// also, to avoid throttling as well,
				// wait for the queue to empty every after 100 messages
				queue.onEmpty().then(() => {
					add(line);
					cb();
				});
github mtconnect / mtconnect-agent / src / adapter.js View on Github external
function writeDataLoop(socket, countValue, delay) {
  let count = countValue;
  while (count) {
    lineReader.eachLine(simulationFile, (line) => {
      setTimeout(() => {
        try {
          socket.write(`${line}\n`);
        } catch (e) {
          common.processError(`Error: ${e}`, false);
        }
      }, Math.floor(Math.random() * delay)); // Simulate delay
    });
    count = count - 1;
  }
}
github jimhigson / oboe.js-website / read-pages-list.js View on Github external
function readFirstLine(file, callback){
    
    lineReader.eachLine(CONTENT_DIR + '/' + file, function(line, last) {
        callback(line);
        return false; // stop reading the file
    });

}
github erelsgl / nlu-server / node_modules / wordsworth / lib / spell_checker.js View on Github external
SpellChecker.prototype.initialize = function(seedPath,
  trainingDataPath, callback) {

  var self = this;
  reader.eachLine(seedPath, function(line) {
    self.understand(line);
    self.train(line); // train the spelling model with each index term
  }).then(function() {
    // now fully-train the spell-checking feature
    reader.eachLine(trainingDataPath, function(line) {
      self.train(line);
    }).then(callback);
  });
};
github catjsteam / catjs / src / module / extension / inject / action.js View on Github external
counter++;
                });

                return lineobj.line;
            }

            // get scrap info
            scraps.forEach(function (scrap) {
                var commentinfo = scrap.get("commentinfo");
                if (commentinfo) {
                    commentinfos.push({col: commentinfo.end.col, line: commentinfo.end.line, scrap: scrap});
                }
            });

            _lineReader.eachLine(file,function (line) {

                line = _injectCodeByScrap(line);
                lines.push(line + "\n");

                // use 'return false' to stop this madness
                lineNumber++;

            }).then(function () {

                    try {
                        _fs.writeFileSync(file, lines.join(""), {mode: 0777});
                        _fs.chmodSync(file, 0777);
                        _log.debug(_props.get("cat.mdata.write").format("[inject ext]"));

                    } catch (e) {
                        _utils.error(_props.get("cat.error").format("[inject ext]", e));
github aserg-ufmg / apidiff / scripts / node / insertBreakingChangesToDataBase.js View on Github external
var parserFile = function(day, file){

	var i = 1;
	//last == true se fim do arquivo.
	lineReader.eachLine(file, function(line, last) {

		//Quebra a linha pelo separador (;)
		var data = line.split(";");
		console.log(i);
		i++;
		if(data.length >= 12){
			var registry = new Object();
			registry.day = day;
			registry.author	= data[0];
			registry.email	= data[1];
			registry.nameLibrary = data[2];
			registry.changedType = data[3];	
			registry.structureName = data[4];	
			registry.category = data[5];
			registry.idCommit = data[6];
			registry.messageCommit = data[7];
github microsoft / Universal-Language-Intelligence-Service / ulis / tools / bulkTranslateAndTrain.js View on Github external
var output = path.join(__dirname, 'hebrew.out.csv');

var outStream = fs.createWriteStream(output);

var ulis = require('../lib/ulis');
var config = require('./config');

//setup ulisClient
var ulisClient = new ulis.getClient({
    lang:'he',
    bingTranslate_clientId: config.get('TRANSLATE_CLIENT_ID'),
    bingTranslate_secret: config.get('TRANSLATE_CLIENT_SECRET'),
    luisURL: config.get('LUIS_ENDPOINT')
});

lineReader.eachLine(filepath,(line, last, cb) => {
    
	ulisClient.query(line, (err, ulisResponse) => {
		if (err) {
			console.error(`error translating: ${err.message}`);
			return cb(err);
		}

		outStream.write(`${line}, ${ulisResponse.translatedText}\n`, () => {
			if (last) {
				outStream.close();
				console.log('done');
			}
			else return cb();
		});
	});
});

line-reader

Asynchronous, buffered, line-by-line file/stream reader

MIT
Latest version published 9 years ago

Package Health Score

53 / 100
Full package analysis

Popular line-reader functions