FIND YOUR NEXT FEW LINES

Results for “generator”

Small, practical examples. Search by task or narrow things down below.

10 snippets foundClear filters
JavaScriptPromises & iteration protocols

Clean up a generator after an early break

JavaScript: Breaking a for-of loop closes a generator and runs its finally block.

JavaScript✓ Tested
TypeScriptPromises & iteration protocols

Clean up a generator after an early break

TypeScript: Breaking a for-of loop closes a generator and runs its finally block.

TypeScript✓ Tested
JavaScriptPromises & iteration protocols

Produce a lazy sequence with a generator

JavaScript: A generator yields one value per iteration without building an intermediate array.

JavaScript✓ Tested
TypeScriptPromises & iteration protocols

Produce a lazy sequence with a generator

TypeScript: A generator yields one value per iteration without building an intermediate array.

TypeScript✓ Tested
JavaScriptPromises & iteration protocols

Consume an asynchronous sequence

JavaScript: for await waits for each value of an async iterator in sequence.

JavaScript✓ Tested
TypeScriptPromises & iteration protocols

Consume an asynchronous sequence

TypeScript: for await waits for each value of an async iterator in sequence.

TypeScript✓ Tested
JavaScriptPromises & iteration protocols

Delegate iteration to another iterable

JavaScript: yield-star forwards items from another iterable while retaining generator composition.

JavaScript✓ Tested
TypeScriptPromises & iteration protocols

Delegate iteration to another iterable

TypeScript: yield-star forwards items from another iterable while retaining generator composition.

TypeScript✓ Tested
PythonFunctions & error handling

Yield values on demand

Python: Use a generator to produce a sequence without storing all intermediate values.

Python✓ Tested
PythonIteration & sequences

Find the first matching value with a fallback

Python: Pass a generator and default to next to avoid building an intermediate list.

Python✓ Tested