Skip to content

delimit(chars) #31

Open
wants to merge 1 commit into from

2 participants

@ralouphie

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'.

@jedmao
jedmao 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'
};
@jedmao
jedmao 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
Something went wrong with that request. Please try again.