2016-04-12 27 views
0

Aşağıda, düğüm j'leri ile 'line-by-line' için şablon. 'un şimdi npm'yi destekleyen sunucu tarafı meteor 1.3 ile çalışması nasıl değiştirildi?meteor 1.3 npm hattı ile satır

  var LineByLineReader = require('line-by-line'), 
     lr = new LineByLineReader('big_file.txt'); 

     lr.on('error', function (err) { 
     // 'err' contains error object 
      }); 

      lr.on('line', function (line) { 

      }); 
+0

kullanım Meteor.bindEnvironment geri çağrıları 'işlevini' yerine? – user3078524

cevap

0
`var future = new Future(); 

    lr = new LineByLineReader('/home/mark/big_file.txt'); 

    console.log("got new line reader"); 

    lr.on('error',Meteor.bindEnvironment(function (err) { 
    // 'err' contains error object 
    })); 

    lr.on('line', Meteor.bindEnvironment(function (line) { 
    // 'line' contains the current line without the trailing newline  character. 

     console.log("got line " + line); 
})); 


    lr.on('end', Meteor.bindEnvironment(function() { 
// All lines are read, file is closed now. 
    console.log("NOW DONE"); 
    future.return("hello joe"); 
})); 


    var requestResults = future.wait(); 

    } 
+0

oops future.wait() öğesini döndürür; – user3078524

İlgili konular