asap
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
ASAP is a high-priority task queue for Node.js and browsers, primarily utilized by promise and asynchronous observer libraries. The asap
function in this package enables the execution of a task as soon as possible, right after the completion of the current event and previously scheduled tasks. The package provides a fast event queue that executes tasks until it is empty, optimizing the programming process by scheduling events to occur before yielding for IO, reflow, or redrawing. It's important to note however, that ASAP may interfere with smooth animation and may cause issues in interactive events if the task queue is not empty.
To use asap
, you simply import it in your JavaScript file and execute your tasks within the asap
function. Here's a basic usage example:
var asap = require('asap');
asap(function() {
// ... your task here ...
});
ASAP can be used recursively without causing stack overflow. However, usage must be checked for infinite loop situations:
function loop() {
asap(loop);
}
loop();
In case of tasks that may throw exceptions, there's an alternative asap/raw
module, which provides the underlying implementation minus the error checking:
var rawAsap = require('asap/raw');
rawAsap(function () {
// ... task that may throw an exception ...
});
Remember that if the task does throw an error, you will need to manually call rawAsap.requestFlush()
before throwing the error or any time after.
The comprehensive documentation and source code for ASAP can be found on its GitHub repository. This is the primary location where developers can learn more about the functionality, usage details, compatibility, and the underlying principles of the asap
package.