I am getting the below result where I'm looping something.
But I'm unable to get the [["PromiseValue"]]
object.
Anyone please help me to do this.
Update :
Code I used for it.
function list(dir) {
const walk = entry => {
return new Promise((resolve, reject) => {
fs.exists(entry, exists => {
if (!exists) {
return resolve({});
}
return resolve(new Promise((resolve, reject) => {
fs.lstat(entry, (err, stats) => {
if (err) {
return reject(err);
}
if (!stats.isDirectory()) {
return resolve({
// path: entry,
// type: 'file',
name: path.basename(entry),
time: stats.mtime,
size: stats.size
});
}
resolve(new Promise((resolve, reject) => {
fs.readdir(entry, (err, files) => {
if (err) {
return reject(err);
}
Promise.all(files.map(child => walk(path.join(entry, child)))).then(children => {
resolve({
// path: entry,
// type: 'folder',
name: path.basename(entry),
time: stats.mtime,
entries: children
});
}).catch(err => {
reject(err);
});
});
}));
});
}));
});
});
}
return walk(dir);
}
This is the code I used to convert the folder Structure to JSON Object.
But, this one gives the above result and I couldn't get the output form it.