Skip to content

Instantly share code, notes, and snippets.

@dtipson
Last active December 26, 2023 03:59
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/8e1e660e856511d530f52c130987af30 to your computer and use it in GitHub Desktop.
Save dtipson/8e1e660e856511d530f52c130987af30 to your computer and use it in GitHub Desktop.
A pipeline version
await pipe(
postIds[Symbol.iterator](),// creates a generator from a plain array of postIds
chunkGen(5),// generator that pulls in 5 numbers and yields them out in arrays of 5
mapGen(map(fetchById)),// generator that takes in arrays of numbers & turns them into arrays of requests
spreadBatchesAsyncGen,// async generator that spreads arrays of resolved promises & emits one promise at a time
forEachAsyncGen(renderPost)// a function that consumes the generator & does something with each result
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment