filewalker

Is there any directory walker in ts / js using an async iterator?

别来无恙 提交于 2021-02-11 14:57:22
问题 I found plenty of walkers on npm but none is using an asynchronous iterator. Most of them are either using a callback or a promise leading to memory leaks on huge directories. Is there any recent library using the following pattern: async function* walk(dirPath) { // some magic… yield filePath; } To then use it like: for await (const filePath of walk('/dir/path')) { console.log('file path', filePath); } 回答1: Okay, I simply made this walker using the synchronous readdir, it is very fast and