Skip to content

Instantly share code, notes, and snippets.

@medfreeman
Created July 14, 2020 10:47
Show Gist options
  • Save medfreeman/41173b560fc2a29c476552af46d3e72b to your computer and use it in GitHub Desktop.
Save medfreeman/41173b560fc2a29c476552af46d3e72b to your computer and use it in GitHub Desktop.
Generator sequence in typescript
export function* sequence<T extends readonly unknown[] = readonly unknown[]>(
sagas: readonly ((...args: T) => Generator<unknown, void>)[],
args: T
) {
for (const saga of sagas) {
yield* saga(...args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment