Answer the question
In order to leave comments, you need to log in
Node.js recursive output of an async function?
There is an asynchronous function! which reads files, parses them, then checks for a link to the parent file, and recursively runs through the dependency chain ... replenishing the stack.
example below (code is not valid, but readable)
let getParent(file, cb)=>{
readFile(file , (err,data)=>{
parse(data, (err, jsObject)=>{
cb(jsObject.parent);
})
})
};
let stack = []
getParent('main.file'(err,parent)=>{
if(!parent){return;}
stack.push(parent);
getParent(parent(err,parent)=>{
if(!parent){return;}
stack.push(parent);
//getParent callback hell
})
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question