Promises/A+ 1.1 specification (and Deferred provider), suitable for inclusion in larger libraries and projects. This implementation provides the core functionality required to leverage asynchrony / tasks / futures / promises within any project or library
(including browsers and Node.js), facilitating simpler, more expressive, more maintainable code.
- No external dependencies.
- Lightweight: ~6Kb minified, ~1.6Kb minified & GZIPped
- A Node.js module published on npm.
- Conversion methods to quickly turn synchronous, asynchronous, and Node.js-style asynchronous methods into Promise-generating methods. See the
Convert class / namespace for more details.
- A quick and convenient way to turn all Node.js and Node.js-like asynchronous methods into Promise-generating methods. See the
Convert.fromNodeAsyncMethod method documentation for more details.
- Uses the best scheduling mechanism available, whether it be
setImmediate, setTimeout, or a custom implementation.
- A convenient MIT license.
Whatever your terminology choice, the application of promises / futures / tasks / asynchronous constructs to most programming endeavors produces code that is more expressive, more responsive, more efficient, and more maintainable. Utilizing a simple asynchrony
pattern allows the creation of libraries that express events and the production of future values without the need for manually-created, repetitive, fragile constructs. The goal of this project is to provide a "pluggable," bundling-ready, well-documented,
Though jQuery and other libraries provide promises and deferred execution options, they are but small components of larger systems that require the entire library to be present, creating a rather hefty dependency and potentially-long page load times. In
contrast, this library targets the light-weight, "initial loading" scenarios that bridge the gap between "document loading" and library readiness. Moreover, unlike many other implementations of promises, which implement their
then methods as executing callbacks immediately if the instance is already complete, all callbacks in this implementation conform to the specification and are scheduled for later execution, providing a fast, consistent
flow of execution.
Suggestions for improvement are always welcome and will be integrated as-appropriate.
Automated testing has been rigorously and thoroughly applied to this project using these tests (all of which pass):
- A wrapper that applies the full
Promises/A+ 1.1 test suite.
- A set of QUnit tests that provide cross-browser testing for Promise functionality, Promise extensions, and conversion methods.
Where They're Used
Optionally, let me know what projects you've developed using this library and I'll feature them on the project page. It's always nice to see where a project gets incorporated...