run-async is a utility method designed to normalize the execution of functions that can operate synchronously, asynchronously via a `this.async()` callback, or by returning a Promise. This library is particularly useful for authors of middleware or plugins that need to accept user-provided functions with varying asynchronous patterns, ensuring a consistent execution flow. The current stable version is 4.0.6, and the project demonstrates an active maintenance cadence, addressing dependency issues and enhancing functionality across major versions. A key differentiator is its ability to abstract away the underlying async mechanism, providing a single interface, and its current status as a dependency-free package since version 2.4.1, which improves reliability and reduces supply chain risks.
npm install run-asyncVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `runAsync` to execute functions that use `this.async()`, return a Promise, or return a synchronous value. Also includes an example of `runAsync.cb` for Node.js callback-style functions.
Migrate your usage to consume the returned Promise (e.g., `runAsync(func)(args).then(cb)`) or ensure your callback handling is compatible with both Promise-based and traditional callback flows.
Ensure that any function passed to `runAsync.cb` explicitly defines all its parameters, including the final callback argument.
Be aware that `runAsync` will always return a Promise for consistent behavior across Node.js versions, which might slightly change execution flow compared to pre-2.2.0 versions on older Node.js.
Upgrade `run-async` to version 2.4.1 or higher to remove the `is-promise` dependency and ensure a more stable, dependency-free experience.
Upgrade your Node.js runtime to a supported version (e.g., 0.12 or higher as per package.json engines) to ensure native Promise support or proper polyfill handling by `run-async`.
Ensure `runAsync` is called such that the wrapped function's `this` context is correctly bound or provided by `run-async` itself. Avoid using arrow functions for the wrapped function if you intend to use `this.async()`, as arrow functions lexically bind `this`.
Review your asynchronous logic to ensure that `done()`, `resolve()`, or `reject()` are called exactly once per `runAsync` invocation, even in error scenarios. Add guards to prevent multiple calls.
No dependency data recorded yet.