Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd option to split() to remove matching characters from emitted chunks #8
Comments
This comment has been minimized.
This comment has been minimized.
|
with your patch this would be really easy to add. there is already a way to do this with string.split: 'a:b:c'.split(/(:)/)
// ['a', ':', 'b', ':', 'c']
this is technically a breaking change, but since 99% of the usecases for this is to make newline seperated json, or otherwise to break on whitespace and then feed it into a parser, I don't think it will affect actual usage. since it was so simple after your patch, I've implemented this already, cheers! |
This comment has been minimized.
This comment has been minimized.
|
Great! I just added a pull request to keep the behaviour compatible with the old API... up to you: |
dominictarr
closed this
May 21, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mhart commentedMay 21, 2012
This would bring it closer to String.split behaviour (at the moment you're trimming each line in test/split.asynct.js to do the comparison - this wouldn't account for leading spaces for example)
It would also allow for splitting on Regex patterns, because the matched characters wouldn't need to be re-emitted.
Happy to do a pull request for this, but figured I'd wait to see what you thought of #7 first.