2016-04-12 11 views
0

以下は、ノードjsを含む「行単位」のテンプレートです。 はどのように変更され、npmをサポートするサーバー側の流星1.3で動作するのですか?流星1.3とnpm行ごと

  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

は、使用Meteor.bindEnvironmentコールバックで '関数' を置換するには? – user3078524

答えて

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 return future.wait(); – user3078524

関連する問題