A pattern for recursion with Promises - in this example, walking a directory structure.
readDirRecursive()
is called with a starting directory and will itself return aPromise
.- Internally
readDir()
is called and passed starting directory to read from. - A list of directory items is returned by
getItemList()
as aPromise
, which in turn is chained togetItemListStat()
to stat each item to determine if file or directory. - Finalised list then passed to
processItemList()
: