Skip to content Skip to sidebar Skip to footer

Conforming My Readpackagefiles To Fit Inside "parallel" Function

I got a lot of help from this SO question around grabbing directories and searching files. I'm trying to conform my readPackageFiles function to use the Parallel function given to

Solution 1:

I was hoping you'd take a closer look at the linked Q&A's. I was suspecting you needed something like this and this function, readPackages, was in the first link I shared with you -

const { readFile } =
  require ("fs") .promisesconst readPackages = async (path = ".") =>
  Parallel (search ("package.json", path))
    .map (readFile)
    .then
      ( buffers =>
          buffers .map (b =>JSON .parse (String (b)))
      )

readPackages (".") .then (console.log, console.error)
// [ ... ]

Note, fs-extra is not required in any of my answers.

Post a Comment for "Conforming My Readpackagefiles To Fit Inside "parallel" Function"