Closed jaidetree closed 2 years ago
Found myself needing this when implementing a recursive readdir function with fs/promises.readdir.
Was able to work around it but p/mapcat would be cleaner I feel:
(defn readdir [dirpath] (p/->> (fs/readdir dirpath #js {:withFileTypes true}) (map (fn [dirent] (let [filepath (.join path dirpath (.-name dirent))] (cond (.isDirectory dirent) (readdir filepath) (.isFile dirent) [filepath] :else [])) )) (p/all) (reduce #(into %1 %2) [])))
Found myself needing this when implementing a recursive readdir function with fs/promises.readdir.
Was able to work around it but p/mapcat would be cleaner I feel: