purescript-node / purescript-node-fs

Node.js file I/O for purescript
MIT License
33 stars 34 forks source link

Implement Watch Api bindings #82

Open wclr opened 9 months ago

wclr commented 9 months ago

It is not large API surface: watch, watchFile, unwatchFile, FSWatcher, StatWatcher.

What do you think, should it go to a separate module Node.FS.Watch?

srghma commented 2 weeks ago

definitely, it's in node:fs

https://nodejs.org/docs/latest/api/fs.html#fswatchfilename-options-listener

srghma commented 2 weeks ago

also glob

https://nodejs.org/docs/latest/api/fs.html#fsglobpattern-options-callback

https://nodejs.org/docs/latest/api/fs.html#fsglobsyncpattern-options

srghma commented 2 weeks ago

https://chatgpt.com/share/66ff459b-140c-8000-bad0-b45dada09474

Callback API -> missing methods:

  1. fs.cp (for copying directories recursively)
  2. ~fs.createReadStream~
  3. ~fs.createWriteStream~
  4. fs.exists (deprecated in favor of fs.access)
  5. fs.fchmod
  6. fs.fchown
  7. fs.fdatasync
  8. fs.fstat
  9. fs.fsync
  10. fs.ftruncate
  11. fs.futimes
  12. fs.glob
  13. fs.lchmod
  14. fs.lchown
  15. fs.lutimes
  16. fs.openAsBlob
  17. fs.opendir
  18. fs.readv
  19. ~fs.realpath.native~
  20. fs.statfs
  21. fs.unwatchFile
  22. fs.watch
  23. fs.watchFile
  24. fs.writev

Summary:

The delta, or missing methods not currently exported by your code, includes many of the specialized methods, ~especially related to streams (createReadStream, createWriteStream)~, file descriptors (fchmod, fchown), synchronization (fdatasync, fsync), and utility functions like glob, watch, statfs, etc.

Synchronous API -> missing methods:

Missing Methods to Add to Your Library:

  1. fs.cpSync

    • Missing: cpSync (for copying directories/files recursively).
  2. fs.fchmodSync

    • Missing: fchmodSync (change file mode with file descriptor).
  3. fs.fchownSync

    • Missing: fchownSync (change file ownership with file descriptor).
  4. fs.fdatasyncSync

    • Missing: fdatasyncSync (synchronize a file's in-core state with storage device).
  5. fs.fstatSync

    • Missing: fstatSync (retrieve file status using file descriptor).
  6. fs.ftruncateSync

    • Missing: ftruncateSync (truncate file to specified length with file descriptor).
  7. fs.futimesSync

    • Missing: futimesSync (change file timestamps with file descriptor).
  8. fs.globSync

    • Missing: globSync (find files matching a pattern).
  9. fs.lchmodSync

    • Missing: lchmodSync (change file mode for symbolic link).
  10. fs.lchownSync

    • Missing: lchownSync (change ownership of a symbolic link).
  11. fs.lutimesSync

    • Missing: lutimesSync (change symbolic link timestamps).
  12. fs.opendirSync

    • Missing: opendirSync (open directory for reading its contents).
  13. fs.readvSync

    • Missing: readvSync (read multiple buffers from a file descriptor).
  14. ~fs.realpathSync.native ~

    • Missing: realpathSync.native (use native realpath implementation).
  15. fs.statfsSync

    • Missing: statfsSync (retrieve filesystem statistics).
  16. fs.writevSync

    • Missing: writevSync (write multiple buffers to a file descriptor).

Methods to Remove (Deprecated or Removed):

  1. None of the methods you are currently using in the synchronous API are deprecated or removed. All the methods you are using are valid and available.

Summary: