fs: refactoring declaratively with the Array.fromAsync function
The following applies to this PR:
- Replaced the
for await...of
loop withArrayFromAsync()
. - Removed the need for manual array pushing using
ArrayPrototypePush
. - Added
ArrayFromAsync
type toprimordials.d.ts
file - Simplified the overall structure of the async function.
Array.fromAsync
was defined relatively recently, but I used it because I knew it was officially adopted in Node.js v22. (MDN Document)