-
Notifications
You must be signed in to change notification settings - Fork 25
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
Iterator Support for large globs #30
Comments
Is this to avoid blocking the main thread and what would such implementation look like? |
Theres a few things involved here @terkelg There are better implementations then what I did, this just so happened to have been fine for my use case. Concerns:
Notes:
Usage: import fglob from 'fast-glob';
import StreamIteratorAdapter from 'stream-to-async-iterator';
async function process(dirglob ,globOptions) {
const stream = fglob.stream(dirglob, globOptions),
iterator = new StreamIteratorAdapter(stream);
for await (const stat of iterator) {
// processes items individually allowing us to handle massive glob lists without hitting resource limits
}
} |
Thanks for elaborating. This seems a bit complex. Is it possible add as an extension/wrapper around tiny-glob? |
If you can provide a stream option it will allow this use case, and with
time it will get more elegant. We can't do any higher level iteration if we
don't have some async way of processing entries with backpressure.
Usually from the implementations I've seen this comes back to `readdir`,
there are some packages that provide this (like `fast-glob`) and digging
through their code it looks like they use `readdir-enhanced` which via some
magic (I didn't look into that code) manages to provide a stream.
But to make it easier for you I'd wrap the stream and just use and expose
an async iterator via generator functions, otherwise you have to do a bunch
of stream handling and thats error prone and painful.
…On Tue, 6 Nov 2018, 11:56 Terkel, ***@***.***> wrote:
Thanks for elaborating. This seems a bit complex. Is it possible add as an
extension/wrapper around tiny-glob?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#30 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEF36NWuATG6PdCdALz5p-qaXMmirQ1iks5usVzagaJpZM4XXdvf>
.
|
Hi
Consider a method where the return object could be an
Iterator
orAsyncIterator
so that large file globs (as in huge numbers of files) are supported.The text was updated successfully, but these errors were encountered: