-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
Rewrite this library #405
Comments
Would this also result in the use of promises instead of callbacks? |
Yes. |
Could it be something like this? |
@isaacs Do you consider using typescript? |
In addition to a promises API, I'd love to see an async iterator implementation. This would allow async traversal of huge trees without buffering the entire result set in memory, and be easier to use ( In fact, this would make a promises API redundant; there are already libraries that will iterate an async iterator and collect the results in a promise for an array (such as async-iterator-to-array). |
Has tiny-glob done most of the work? It's written in TypeScript, uses Promises. |
I am not intending to use typescript for this. Nothing against TypeScript, but it's not my preference. I have not investigated whether tiny-glob has the same adherence to Bash 4's glob semantics. It's no slight against tiny-glob if it does not, as there are several places where this necessitates arguably less than optimal implementation choices, but there is a value in having a library with a constraint, so I would not suggest that as a replacement unless it does. I figured it would make sense to implement this as an |
Turns out I am using TypeScript for this. #489 Still using regexps though. Gonna close this since the PR covers the changes more correctly. |
Do you have a changelog for v9? Would be nice to have a list of breaking changes so we can upgrade, without having to read through every single commit Thanks for the awesome lib |
@mrmlnc Thanks, I think I need to clean my eyes, I looked for it, but I guess because it's not in CAPS not in the right place :p |
JavaScript has come a long way since I wrote this, and while it's used by a lot of people, it has some definite shortcomings that make it hard to improve and modify.
Rather than the "pile of functions" approach, with everything re-implemented for sync globbing, this should use a class-based approach, where all fs ops are abstracted into methods that can be overridden in a sync child class, like how the internals of node-tar or npm-packlist work.
Consider not relying on regular expressions or minimatch. Ie, write a parser that can take a glob pattern (after splitting up the
{,}
sections) and a path, and return the following possible states:a/**/x/y
againsta/x
would return**/x/y
andy
as patterns that could match against child entries. If the entry is not a dir, this is a NO response.**/x
would match botha/x
anda/x/x
, so comparing it to thea/x
path should say "yes, and"). Return value should include the bits that can match child entries. So,a/**/x/**
againsta/x
would return a "yes and" response with**/x/**
andx/**
as remaining patterns. If the entry is not a dir, this is a YES BUT response.a/*/
matches the dira/x/
, but not the filea/x
)For all of these, walk the string and compare with a finite state machine rather than converting to a regexp.
Fix all the windows stuff. Not sure what to use as a reference implementation here. Mingw bash? LSW?
Consider using a WASM'ed implementation of glob written in rust? Especially if we're not reliant on JS regexps, this makes a lot of sense.
Create a custom error type
I will set aside some vacation time to do this if a handful of people decide to fund this library.
The text was updated successfully, but these errors were encountered: