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

Support predicate argument in read-upto #885

Open
xiaq opened this issue Dec 30, 2019 · 0 comments
Open

Support predicate argument in read-upto #885

xiaq opened this issue Dec 30, 2019 · 0 comments

Comments

@xiaq
Copy link
Member

@xiaq xiaq commented Dec 30, 2019

Originally posted by @xiaq in #831 (comment)

I am considering introducing a read-upto command:

read-upto $last

The command reads from the bytes input, one byte at a time. The argument $last may be one of:

  • A string with a single byte, in which case it specifies the byte to stop reading after;
  • A function, in which case read-upto passes each byte as a string to the predicate, and stops after the predicate outputs a false value.

There is something subtle about read-upto: its output will include the first byte that is equal to $last (if $last is a string) or fails the $last predicate (if $last is a function). This is a consequence of how pipelines work.

The first simpler variant is now implemented, but the second predicate argument remains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.