Promissum
Promissum is a JavaScript library that provides promises with the semantics and terminology described in the [Promises/A+ specification] 1.
Usage
Documentation can be found in the [source] 2.
Example
var sleep = function (s) {
var p = promise();
setTimeout(function () {
p.fulfill(s);
}, s * 1000);
return p;
};
sleep(3)
.then(function (s) {
console.log("Slept for " + s + " seconds.");
});
Installation
Before you download the library, you can try it out in your browser. Go to the following URL and open the JavaScript console.
data:text/html,<script src="https://raw.github.com/andreaslundahl/promissum/v0.1.0/src/promissum.js"></script>
Web browser
- Version [0.1.0] 3 for development.
- Version [0.1.0] 4 for production (minified).
- [HEAD] 5 of the master branch.
Once included, the promise
function is added to window
.
npm
Promissum in the [npm registy] 6.
Once installed, the promise
function can be required with
require("promissum")
.
Dependencies
- A JavaScript environment (e.g. a web browser or Node.js).
- The promises-aplus-tests library (for testing).
Tests
Currently, the test suite can only be run on Node.js. After you have installed it, get the source code and run:
npm test
Alternatives
License
Copyright (c) 2013 Andreas Lundahl. Promissum may be freely distributed under the MIT license. More information can be found in the LICENSE file.