Skip to content

Instantly share code, notes, and snippets.

View gauravnadkarni's full-sized avatar

Gaurav gauravnadkarni

View GitHub Profile
@gauravnadkarni
gauravnadkarni / generator_methods.md
Created October 31, 2025 12:08
generator methods supported
Method Description Common Use
next(value) Resumes the generator’s execution from where it paused at the last yield. Optionally passes a value into the generator, which becomes the result of the yield expression. To continue normal execution.
throw(error) Throws an error inside the generator at the point it was paused. If not caught with a try/catch, it will propagate outside the generator. To handle Promise rejections or inject errors.
**`return(
@gauravnadkarni
gauravnadkarni / when_to_choose_generators_or_async_await.md
Created October 31, 2025 10:00
When to use generators and async/await
Scenario Use Generators Use Async/Await
Processing large or infinite data streams ✅ Ideal - allows lazy evaluation and efficient iteration. ❌ Not suitable - executes eagerly and expects finite results.
Controlling execution flow manually ✅ Best choice - gives precise pause/resume control via next() and yield. ❌ Engine controls execution automatically, limited manual control.
Simplifying asynchronous workflows ⚠️ Possible with helpers like run(), but verbose. ✅ D
@gauravnadkarni
gauravnadkarni / practical_generator_async_await_defferences.md
Created October 31, 2025 09:55
Practical differences between generators and async/await
Feature / Aspect Generators Async/Await
Control Fine-grained, manual control via next() Automatic, sequential execution of awaited Promises
Use Case Iteration, lazy evaluation, custom flow control Simplifying asynchronous code readability and sequencing
Syntax Complexity Requires helper or loop for async flows Native, straightforward, built-in error handling
State Management Maintains execution context, can pause/resume multiple times Maintains context until function completes; no manual pause/resume
Memory / Laziness Can produce values lazily, on demand
@gauravnadkarni
gauravnadkarni / domain_boundaries.md
Created October 17, 2025 14:43
This table illustrates how core business capabilities (Shipment, Tracking) are encapsulated within a Hexagonal Architecture, detailing each Hexagon's primary responsibility and external technical dependencies.
Capability Responsibility External Dependency Hexagon
Shipment Create, update, and store shipment details Database Shipment Hexagon
Tracking Fetch and update location or delivery status External tracking API Tracking Hexagon