Skip to content

Feature: Refactor this to use fs.openDir in future and not fs.readdir #105

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

Closed
frank-dspeed opened this issue Oct 11, 2019 · 6 comments
Closed

Comments

@frank-dspeed
Copy link

frank-dspeed commented Oct 11, 2019

NodeJS > 12.11.1 will have async readdir support Landed in cbd8d71 ( nodejs/node@cbd8d71 ) as fs{Promises}.opendir(), which returns an fs.Dir, which exposes an async iterator.

to stay compatible we could implament it with the same stream interface and simply check if fs.openDir is there if not fallback to existing implamentation.

This is a lobby Request <3 by the microsoft/vscode community

@paulmillr
Copy link
Owner

easy

@paulmillr
Copy link
Owner

See branch v4 for implementation: https://github.com/paulmillr/readdirp/tree/v4

Execute node examples/list, ensure to pass big directory there.

  1. v4 branch ditches readable stream in favor of async generators (node 10+).
  2. This allows to speed-up a file tree of 45k entries from 1.6 sec to 500ms (3x).
  3. opendir works, you'll need node 12.12, it's 3x slower than readdir — MEH! It's as slow as current readdirp-v3.

@yisibl
Copy link

yisibl commented Nov 29, 2022

Hi, @paulmillr Why is opendir slower instead?

@paulmillr
Copy link
Owner

@yisibl ?

@yisibl
Copy link

yisibl commented Nov 29, 2022

opendir works, you'll need node 12.12, it's 3x slower than readdir — MEH! It's as slow as current readdirp-v3.

@paulmillr
Copy link
Owner

What is the question? Open dir is 3x slower. Why is it slower? I don't know. Shitty node.js implementation.

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

No branches or pull requests

3 participants