首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >逐行使用npm的meteor 1.3

逐行使用npm的meteor 1.3
EN

Stack Overflow用户
提问于 2016-04-13 00:59:43
回答 1查看 48关注 0票数 0

下面是“line-by-line”with node js的模板。现在支持npm的服务器端meteor 1.3是如何改变的?

代码语言:javascript
复制
         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) {

          });
EN

回答 1

Stack Overflow用户

发布于 2016-04-13 02:25:37

代码语言:javascript
复制
    `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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36579640

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档