How can I read each file in a directory and directly run a function in node readdir?

my understanding of fs.readdir in node is that it reads all files in a directory asynchronously, but only makes them available as an array once they’re all fulfilled. Is it possible to run a function on each file as soon as that individual file is ready (i.e. not to wait for all of them)?

My current implementation is as follows:

fs.readdir(DIR, async (err, files) => {
      if(err) console.log(err)
      const promises = files.map(file => doSomething(file))
      try {
        await Promise.allSettled(promises);
      } catch (error) {
        console.error('Error processing array:', error);
      }  
})

which runs doSomething on each file asynchronously but that still waits for all files to be determined first