Skip to content

Instantly share code, notes, and snippets.

@dtipson
Last active December 26, 2023 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtipson/97feb25f851f204ea74b5bb04b02ed92 to your computer and use it in GitHub Desktop.
Save dtipson/97feb25f851f204ea74b5bb04b02ed92 to your computer and use it in GitHub Desktop.
An even simpler pipeline
const outputs = await pipe(
postIds,// array of numbers, which is... already an iterable
mapGen(fetchById),// generator of an array of eventually all resolved promises (requested in chunks of 3)
chunkGen(5),// generator of arrays of 5 promises, our "batch"
spreadBatchesAsyncGen,// async generator of individual resolved promises
forEachAsyncGen(renderPost)// Promise of an array of numbers
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment