{"id":24929,"library":"async-compiler","title":"async-compiler","description":"A JavaScript compiler that transforms functions annotated with @async JSDoc tag into code using Promises for sequential asynchronous execution. Version 1.0.20 is the current stable release, with no recent updates indicating ongoing maintenance. It provides a simpler alternative to nested callbacks or promise chains by allowing developers to write asynchronous code in a synchronous style. Unlike native async/await (ES2017), it requires a compile step and a runtime library (async-compiler-runtime), and does not support advanced features like error handling or parallel execution patterns.","status":"maintenance","version":"1.0.20","language":"javascript","source_language":"en","source_url":"https://github.com/stonezhong/async-compiler","tags":["javascript","async","function","compiler"],"install":[{"cmd":"npm install async-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add async-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add async-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime support for compiled code; must be installed and required in the output.","package":"async-compiler-runtime","optional":false}],"imports":[{"note":"The runtime library is CommonJS-only, no ESM exports.","wrong":"import AsyncTool from 'async-compiler-runtime';","symbol":"AsyncTool","correct":"var AsyncTool = require('async-compiler-runtime');"}],"quickstart":{"code":"// async-example.js\nvar AsyncTool = require('async-compiler-runtime');\n\nfunction add(x, y) {\n  return Promise.resolve(x + y);\n}\nfunction mul(x, y) {\n  return Promise.resolve(x * y);\n}\n\n/** @async **/\nfunction foo() {\n  return mul(add(3, 4), add(5, 6));\n}\n\nfoo().then(function(v) {\n  console.log('Result:', v);\n});\n\n// Command to compile:\n// node --harmony node_modules/async-compiler/compile.js --input async-example.js --output async-compiled.js\n// node --harmony async-compiled.js","lang":"javascript","description":"Shows a complete example: two async functions, a function with @async tag that composes them, and the compile/run commands."},"warnings":[{"fix":"Use node --harmony or update Node.js to version 6+ where destructuring is enabled by default (though --harmony still recommended).","message":"Requires Node.js with --harmony flag for destructuring support (e.g., Node 6+).","severity":"breaking","affected_versions":"all"},{"fix":"Migrate to native async/await syntax and remove the compile step.","message":"Native async/await (ES2017) is widely supported in Node 7.6+ and modern browsers, making this compiler unnecessary for most projects.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure JSDoc comment starts with /** and ends with */, with @async inside.","message":"The function must be annotated with exactly `/** @async **/` (with two asterisks on opening). Single-line comment /* */ will be ignored.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install async-compiler-runtime: npm install async-compiler-runtime (or include as dependency). Then add `var AsyncTool = require('async-compiler-runtime');` at the top of your source file before using @async functions.","cause":"The runtime package is not installed or not required in the compiled output.","error":"Error: Cannot find module 'async-compiler-runtime'"},{"fix":"Run with --harmony flag: node --harmony compiled.js","cause":"Node.js version does not support destructuring or arrow functions used in compiled output without --harmony flag.","error":"SyntaxError: Unexpected token function"},{"fix":"Ensure that inside @async functions, all asynchronous calls return Promises (e.g., using the provided add/mul functions). The final return value of the @async function must be a Promise (typically the result of the outermost async call).","cause":"The function body does not contain an async operation returning a Promise, or the return value is not a Promise.","error":"Error: @async function must return a Promise"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}