MCPcopy Create free account
hub / github.com/PicoCreator/smol-dev-js / nestedFileObjToStrFormat

Function nestedFileObjToStrFormat

src/util/scanDirectory.js:10–23  ·  view source on GitHub ↗

* Utility function, used to convert nested file object to string format * @param {Object} nestedFileObj * @param {String} prefixTab * @returns

(nestedFileObj, prefixTab="")

Source from the content-addressed store, hash-verified

8 * @returns
9 */
10function nestedFileObjToStrFormat(nestedFileObj, prefixTab="") {
11 let result = "";
12 for(const key in nestedFileObj) {
13 const value = nestedFileObj[key];
14
15 if(typeof value == "object") {
16 result += `${prefixTab}${key}/\n`;
17 result += nestedFileObjToStrFormat(value, prefixTab+" ");
18 } else {
19 result += `${prefixTab}${key}\n`;
20 }
21 }
22 return result;
23}
24
25/**
26 * Given the directory, and the option object with the following options

Callers 1

scanDirectory.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected