Create intermediate Works with: Any AI

Convert Callback Code to Modern Async Style

Before after

Rewrite code step by step while keeping behaviour identical.

The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.

[VERIFY] is an editorial flag, not a blank to fill. Wherever the prompt shows [VERIFY], check that item against a reliable source before you use it.

Rate this prompt

Loading ratings…

Convert this code to a modern asynchronous style: [CODE]. Language and runtime version: [RUNTIME]. Error handling expectations: [ERROR_HANDLING]. Tests: [TESTS].

First explain what the code does and the order of operations. Then rewrite in small steps, showing each intermediate version. Preserve error behaviour, including what happens on failure of each step and whether operations run in sequence or in parallel. Point out any place where the original behaviour looks like a bug, and do not silently fix it.

Return the final code, a table of behaviour differences if any, tests to run before and after, and notes on cancellation, timeouts and resource cleanup. Mention version-specific syntax I should confirm [VERIFY].

Provide a before and after example with a small invented snippet, showing the nested callbacks and the flattened version, together with the test that confirms they behave the same. Explain common traps: forgotten await, errors swallowed in parallel tasks, unhandled rejections and loops that start all operations at once. Add a checklist for reviewing converted code, and a note on timeouts and retries that did not exist in the original.

Fill in before use

Optional: type your details and the prompt above updates. Nothing is saved or sent.

Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.

Related prompts