endojs / playground

Experimental caplets and plugins for the Endo Pet Dæmon
0 stars 2 forks source link

file / directory watcher #12

Open dckc opened 7 months ago

dckc commented 7 months ago

For example, an async iterator that advances every time a file is added to a directory.

dckc commented 7 months ago

I wonder how much of it can be built with generative AI. Let's be a little more explicit with the description and use it as a prompt:

As a developer, I want a JavaScript file watcher library module. It should let me make an async iterator that advances each time a file is added to a directory. The value should be an object with methods to get the file's name and to read the file contents. Choose an appropriate npm package for watching files at least on linux.

Stretch goals:

  1. The module should have a function to make objects representing directories. In addition to a method to get an async iterator as above, the objects should have a join(segment1, ...segments) method that returns an object representing a subdirectory.
  2. unify the directory and file APIs.
  3. use dependency injection for access to the filesystem (and in general, all IO).