codeflash-internal/django/aiservice/optimizer/prompts/javascript/async_user_prompt.md
2026-01-14 22:15:27 -08:00

948 B

Rewrite this asynchronous JavaScript/TypeScript program to run faster while preserving all async behavior.

CRITICAL ASYNC REQUIREMENTS:

  • The code contains async functions - you MUST keep them async
  • ALL async function signatures must be preserved exactly
  • ALL await expressions must be maintained (unless replaced with functionally equivalent async operations)
  • Do NOT convert async functions to synchronous functions
  • Preserve concurrent execution patterns and Promise handling
  • Maintain proper async/await flow and exception handling

Async Optimization Guidelines:

  • Consider using Promise.all() for concurrent execution when beneficial
  • Batch independent async operations instead of sequential awaits
  • Optimize async I/O operations and use streaming where appropriate
  • Use worker threads for CPU-intensive tasks to avoid blocking the event loop
  • Implement proper error handling in async contexts

{source_code}