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

Add option to split() to remove matching characters from emitted chunks #8

Closed
mhart opened this Issue May 21, 2012 · 2 comments

Comments

Projects
None yet
2 participants
@mhart
Contributor

mhart commented May 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.

@dominictarr

This comment has been minimized.

Owner

dominictarr commented May 21, 2012

with your patch this would be really easy to add.
basically, just have to not append the matched character.

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,

3ac501c
a3f4e66

cheers!

@mhart

This comment has been minimized.

Contributor

mhart commented May 21, 2012

Great! I just added a pull request to keep the behaviour compatible with the old API... up to you:

#9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment