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

Add xeval #581

Merged
merged 4 commits into from
Sep 11, 2019
Merged

Add xeval #581

merged 4 commits into from
Sep 11, 2019

Conversation

nayeemrmn
Copy link
Contributor

@nayeemrmn nayeemrmn commented Sep 4, 2019

Experimenting with moving deno xeval here.
CC @bartlomieju @kevinkassimo

@kevinkassimo
Copy link
Contributor

kevinkassimo commented Sep 4, 2019

It is embarrassing, but I have to admit I just spot a bug with the chunks implementation I did before... The multi-char delimiter matching is throwing away incorrect parts, resulting in things like !DEDELIM!DELIM! incorrectly delimited with -d 'DELIM' set... We need KMP or Boyer Moore for this

@bartlomieju
Copy link
Member

@kevinkassimo maybe it's worth fixing the problem in this PR? IMHO it makes sense to move xeval to deno_std

@kevinkassimo
Copy link
Contributor

@bartlomieju I had a PR fixing the behavior in the deno repo. I’ll wait for it to be reviewed and see we can completely move it here

@kevinkassimo
Copy link
Contributor

I was also thinking if we should move chunks to io/? Since it takes a Reader interface and might be also useful in other scenarios.

kevinkassimo and others added 3 commits September 5, 2019 01:47
Co-authored-by: Nayeem Rahman <muhammed.9939@gmail.com>
@bartlomieju
Copy link
Member

I was also thinking if we should move chunks to io/? Since it takes a Reader interface and might be also useful in other scenarios.

Yes that makes sense, I'd also suggest adding lines function that is an alias for chunks - it's been requested many times.

@nayeemrmn
Copy link
Contributor Author

Well it behaves like String::split() but for Readers. I would call it readAndSplit() or maybe even just split(). chunks() is vague.

@kevinkassimo
Copy link
Contributor

@Narendra-Kamath I like the idea of including split in the name, but readAndSplit sounds a bit too long? Maybe readSplit() or readDelim() (align with readLine)? Also we can add a maxSplit property to it, such that readSplit(reader, "\n", { maxSplit: 2 }) will yield at most 2 strings.

Also we might want to distinguish async function* readSplit(r: Reader, delim: Uint8Array): AsyncIterableIterator<Uint8Array> and readStrSplit(r: Reader, delim: string): AsyncIterableIterator<string>. (This change should be quite simple)

Also I noticed https://github.com/denoland/deno_std/blob/master/io/readers.ts . We can maybe also implement a DelimitedReader

@nayeemrmn
Copy link
Contributor Author

distinguish async function* readSplit(r: Reader, delim: Uint8Array): AsyncIterableIterator<Uint8Array> and readStrSplit(r: Reader, delim: string): AsyncIterableIterator<string>.

Yeah. Most accurately it reads, decodes to string and splits. readStrSplit() checks every box.

@bartlomieju
Copy link
Member

Also I noticed https://github.com/denoland/deno_std/blob/master/io/readers.ts . We can maybe also implement a DelimitedReader

👍 additionally Rust has lines method implemented on BufReader - I believe we should replicate this function on Deno's BufReader

As for the renaming of chunks I'd suggest readDelimitedChunks.

@nayeemrmn can you update the PR? There are a few issues waiting on this functionality :)

@nayeemrmn
Copy link
Contributor Author

@bartlomieju I think moving chunks() should be a separate PR. It would get merged a lot sooner and I can rebase this one. @kevinkassimo?

@kevinkassimo
Copy link
Contributor

I'm fine with landing this first (as long as we don't expose chunks or equivalent here)

@bartlomieju
Copy link
Member

@ry please review

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ry ry merged commit a2cae36 into denoland:master Sep 11, 2019
@nayeemrmn nayeemrmn deleted the xeval branch September 11, 2019 16:49
ry pushed a commit to ry/deno that referenced this pull request Oct 9, 2019
Co-authored-by: Nayeem Rahman <muhammed.9939@gmail.com>


Original: denoland/std@a2cae36
inverted-capital pushed a commit to dreamcatcher-tech/napps that referenced this pull request Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants