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

delimit(chars) #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

delimit(chars) #31

wants to merge 1 commit into from

Conversation

ralouphie
Copy link

Added delimit(chars) function to accept any characters to delimit the stream with.

Changed lines property to use delimit('\r\n').

This is useful when you want to break the stream up using different characters, for example the null character '\0'.

@jednano
Copy link

jednano commented Aug 3, 2013

This PR was submitted 5 months ago and still no action? This makes me NOT want to contribute to this project. Hey @alphus, this is a great idea and a great PR. If you took it a step further, you could include all the other newline characters. Here, this might help:

var newlines = {
    // Carriage Return followed by Line Feed
    crlf: '\r\n',

    // Line Feed, U+000A
    lf: '\n',

    // Carriage Return, U+000D
    cr: '\r',

    // Vertical Tab
    vt: '\u000B',

    // Form Feed
    ff: '\u000C',

    // Next Line
    nel: '\u0085',

    // Line Separator
    ls: '\u2028',

    // Paragraph Separator
    ps: '\u2029'
};

@jednano
Copy link

jednano commented Aug 3, 2013

@alphus, are null characters considered a newline character or just an end-of-string character? Is there a difference? It seems a bit hazy to me.

BTW, this should help also, a regex I wrote to test or otherwise split by newline characters:

var newlineCharacters = Object.keys(newlines).map(function(key) {
    var value = newlines[key];
    reverseMap[value] = key;
    return value;
});

var newlineCharacterPat = new RegExp(
    '(' + newlineCharacters.join('|') + ')', 'g');

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

Successfully merging this pull request may close these issues.

2 participants