Hoping for a clean way to get an array of filenames in directory
Trying to do something like this:
But I get this:
Property 'map' does not exist on type 'Iterable<DirEntry>'.
Is a for loop the only way?6 Replies
You could turn the iterable into an array with
Array.from
and then map it, if memory is not a concern.This is also kinda interesting: https://github.com/tc39/proposal-iterator-helpers
https://www.npmjs.com/package/es-iterator-helpers
GitHub
GitHub - tc39/proposal-iterator-helpers: Methods for working with i...
Methods for working with iterators in ECMAScript. Contribute to tc39/proposal-iterator-helpers development by creating an account on GitHub.
npm
es-iterator-helpers
An ESnext spec-compliant iterator helpers shim/polyfill/replacement that works as far down as ES3.. Latest version: 1.0.15, last published: 4 months ago. Start using es-iterator-helpers in your project by running
npm i es-iterator-helpers
. There are 75 other projects in the npm registry using es-iterator-helpers.You can use
<Array>.fromAsync
Or go over the board with fp-ts
, which is way more readable
Thanks everyone! Also, walk is awesome. 🙂