-
Notifications
You must be signed in to change notification settings - Fork 7
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
clarification of 'split' event #4
Comments
if you have more question, or does anything concerns you about the anyways, i'll update the readme :) |
that is still a little confusing, but I assume that if the raw stream is like this:
if you are splitting on '\n', the split event will give you: "I am a raw stream", "hear me ROAR", "!!!!!1!!!"
is that correct? the only thing that I think you should add is to go
and then have the BufferStream emit the "split" events as "data" events. |
not quite, "!!!!!1!!!" would be stuck in the buffer because there is no "\n" after it to cut it off. btw thanks for the idea ... plz moar of that ;) |
ah, it might be a good idea to also still emit the last thing. that is usually what you'd want if you are splitting by newlines... maybe add an {inclusive: boolean} option, and default it to true? |
another important nuance: what happens if the stream has split tokens immediately following each other "data\n\ndada"? in http, a double newline is used to signify the end of the header section. |
just discovered, that this allready works :D so it will emit "!!!!!1!!!" on end. |
awesome! On Wed, Sep 21, 2011 at 12:33 PM, ▟ ▖▟ ▖ <
|
stream = new (require('bufferstream'))({size:'flexible', split:'\n'});
stream.on('data', function (line) {console.log(line.length, line.toString())});
stream.write("data\n\ndada");
stream.end(); results in:
|
that is good. On Wed, Sep 21, 2011 at 12:42 PM, ▟ ▖▟ ▖ <
|
btw .. i'm allready cutting off a http header from a cgi script with bufferstream https://codetu.be/team/codetube/blob/master/src/git-http-backend.coffee#L105 |
It it possible to use this without setting-up the 'split' token? I would like to use at as a Stream interface over a Buffer (or a series of Buffers...), without having to wait for any specific token ('data' event is emitted as soon as there is data in the buffer). Did I knock the wrong door? |
yes it is possible. just don't use split :) |
So this is a bug, because no 'data' event is ever sent without a 'split' set, or at least this is what I have found so far... |
where did you found it? have you actually tried it? |
I would have bothered reporting an issue without having actually tried it. believe it or not ;-) I am now using https://github.com/samcday/node-stream-buffer, which does the trick, although it is less sophisticated/feature-ruch compared to node-bufferstream. |
I'm not sure from your readme what the split event emits?
does it emit the buffer up to the just before the token starts?
also, does it join buffers together if they do not already end in a token?
in other words, can I use this to rechunk a stream so that the chunks always break on newlines, for example?
The text was updated successfully, but these errors were encountered: