Open
Conversation
…am with. Changed property to use delimit().
|
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'
}; |
|
@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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added
delimit(chars)function to accept any characters to delimit the stream with.Changed
linesproperty to usedelimit('\r\n').This is useful when you want to break the stream up using different characters, for example the null character
'\0'.