This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Construct a chained array of callbacks that "thread" a sequence of async functions in the smallest possible code. | |
# tldr; call the next async function in fn, "wait" for its callback to store the result and call the next async callback in cb | |
# each async function | |
# accepts 1 callback argument | |
# passes 1 arg of result data to the callback | |
# construct the callback | |
# when callback in cb evaluates, replaces itself in cb array with the result | |
# calls the next callback in cb | |
# after last callback in cb, return joined results stored in cb |