-
Notifications
You must be signed in to change notification settings - Fork 63
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
FS API changes #74
Comments
ping @verpeteren and @efyx on their opinion. |
Started work on above APIs on this branch: https://github.com/cookiengineer/Nidium/tree/feature/fs |
Can somebody help me understand how the tasks and callbacks work or would be implemented, e.g. in the case for fs.readDir() and fs.readDirSync()? I currently have troubles making sense of fs.readDir() because it's firing the callback multiple times, for every single file item. Is that the wanted behaviour? I would guess this is like totally unusable as it will eventually lead to people having to use a cache array anyways... and therefore would just harden the usage of the API. Implementation-wise remove, readDir, readDirSync, createDir and createDirSync are missing. Other methods are implemented, but undocumented and yet have no unit tests. |
I was trying to implement
mkDir()
today, and I figured out that most of the File API is somehow very hard to understand, especially the static methods that can be used likeFile.readSync(path)
.After discussing some things with @paraboul I'd suggest that we need to move some methods from File to the FS object, so that static methods are in one place and not confusing anymore:
Changes to File
File.prototype.rm()
File.prototype.rmrf()
File.prototype.isDir()
File.prototype.listFiles()
becausefs.readDir()
already has identical featuresetChanges to fs
fs.remove(path, (err) => {})
(Boolean) fs.removeSync(path)
fs.createDir(path, (err) => {})
(Boolean) fs.createDirSync(path, options)
(Array) fs.readDirSync(path)
(Boolean) fs.isDir(path)
(Boolean) fs.isFile(path)
So here's some code how it would look like:
PS: I would love to implement this as my first pull request, as it seems that static methods are easier to implement and the relevant method signatures are already in the codebase.
The text was updated successfully, but these errors were encountered: