Last active
December 26, 2023 03:59
-
-
Save dtipson/8e1e660e856511d530f52c130987af30 to your computer and use it in GitHub Desktop.
A pipeline version
This file contains hidden or 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
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