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

[RFC]: add @stdlib/fs/resolve-parent-paths #2565

Closed
3 tasks done
Snehil-Shah opened this issue Jul 11, 2024 · 9 comments · Fixed by #2566
Closed
3 tasks done

[RFC]: add @stdlib/fs/resolve-parent-paths #2565

Snehil-Shah opened this issue Jul 11, 2024 · 9 comments · Fixed by #2566
Assignees
Labels
Accepted RFC feature request which has been accepted. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. Feature Issue or pull request for adding a new feature. JavaScript Issue involves or relates to JavaScript. priority: Normal Normal priority concern or feature request. RFC Request for comments. Feature requests and proposed changes. Utilities Issue or pull request concerning general utilities.

Comments

@Snehil-Shah
Copy link
Member

Description

This RFC proposes adding @stdlib/fs/resolve-parent-paths similar to @stdlib/fs/resolve-parent-path, which instead of a single path, accepts either an array of paths or a regular expression.

Related Issues

No.

Questions

No.

Other

No.

Checklist

  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.
@Snehil-Shah Snehil-Shah added RFC Request for comments. Feature requests and proposed changes. Feature Issue or pull request for adding a new feature. labels Jul 11, 2024
@kgryte kgryte added Utilities Issue or pull request concerning general utilities. Accepted RFC feature request which has been accepted. priority: Normal Normal priority concern or feature request. JavaScript Issue involves or relates to JavaScript. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. labels Jul 11, 2024
@kgryte
Copy link
Member

kgryte commented Jul 11, 2024

@Snehil-Shah Sounds good to me. Thanks for this suggestion!

@Snehil-Shah Snehil-Shah self-assigned this Jul 11, 2024
@Snehil-Shah
Copy link
Member Author

@kgryte For regexp paths, we would have to test the regex with every possible path at each directory level. I wonder how much this would hurt perf?

@kgryte
Copy link
Member

kgryte commented Jul 11, 2024

@Snehil-Shah Yeah, it won't be great. For simple regular expressions, it should be fine, and not much worse than normal string comparison.

@Snehil-Shah
Copy link
Member Author

Snehil-Shah commented Jul 11, 2024

@kgryte I meant, that for an array of strings, we can check if each of the resolved directory (made from each path in array) exists or not. But in case of regexp, we would have to traverse the entire directory at each level to test if it exists or not. So, say if a directory has a 100 files/folders, we would have to traverse and test all of them to see if they satisfy the regexp. Or is there another way that I'm overlooking?

@kgryte
Copy link
Member

kgryte commented Jul 11, 2024

That's correct. We'd need to use readdir, rather than exists. Maybe we should just limit to an array of strings and not support regular expressions.

@Snehil-Shah
Copy link
Member Author

Yeah, we should just stick to an array of strings, as the read-dir approach seems to greatly increase time complexity

@kgryte
Copy link
Member

kgryte commented Jul 11, 2024

Works for me! We can always add sthg for regexps later, possibly a different package.

@Snehil-Shah
Copy link
Member Author

Should I also create an RFC for resolve-parent-paths-by to complete the API set?

@kgryte
Copy link
Member

kgryte commented Jul 11, 2024

Yes, that would be good. Thanks!

gunjjoshi pushed a commit to gunjjoshi/stdlib that referenced this issue Aug 21, 2024
PR-URL: stdlib-js#2566 
Closes: stdlib-js#2565

---------

Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
Co-authored-by: Athan Reines <kgryte@gmail.com>
Reviewed-by: Athan Reines <kgryte@gmail.com> 
Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted RFC feature request which has been accepted. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. Feature Issue or pull request for adding a new feature. JavaScript Issue involves or relates to JavaScript. priority: Normal Normal priority concern or feature request. RFC Request for comments. Feature requests and proposed changes. Utilities Issue or pull request concerning general utilities.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants