Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected behaviour for multiline formats #2

Open
homonecloco opened this issue Mar 4, 2015 · 1 comment
Open

Expected behaviour for multiline formats #2

homonecloco opened this issue Mar 4, 2015 · 1 comment

Comments

@homonecloco
Copy link

In case that a "unit" of information is contained in more than one line, what should be done in the readline method? Intuitively, I would say read the whole unit.
R.

@wilzbach
Copy link
Member

wilzbach commented Mar 5, 2015

Buffer the current unit in the instance.
Have a look at biojs-io-matrix

var mParser = new MParser();
mParser.parseLine("A 1");
mParser.parseLine("B 2 3");
var matrix = mParser.buildMatrix();

In the future we should also use streams and there the pattern gets more obvious and easier to understand. However atm I am a bit worried about the increased size when I add them (#1).

input.on("chunk", function(d){
  if(d = "--"){
    out.write(this.buffer);
   this.buffer = [];
  }else{
   buffer.push(JSON.parse(d)); // adding the current line to the buffer
  }
})
input.on("end", function(d){
  out.write(this.buffer);
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants