promise-simple
0.1.0 • Public • Published js-promise-simple
The simple implementation of CommonJS Promises/A.
Usage
From node.js
var Promise = require('promise-simple');
Promise.defer()
.next(function() {
return "ok";
}, 1000)
.next(function(res) {
console.log(res);
}, 2000);
From browser side javascript
<script src="/path/to/promise-simple.js"></script>
var asyncFunc1 = function() {
var d = Promise.defer();
setTimeout(function() {
d.resolve("first");
}, 1000);
return d;
};
var asyncFunc2 = function() {
var d = Promise.defer();
setTimeout(function() {
d.resolve("second");
}, 1000);
return d;
};
Promise.when(asyncFunc1, asyncFunc2).then(function(results) {
console.log(results[0]);
console.log(results[1]);
});
Testing
Using mocha from Node.js.
or open "test/browser/promise-simple_test.html" by some browser.
Versions
Current Tags
- VersionDownloads (Last 7 Days)
- 0.1.0
54
Version History
- VersionDownloads (Last 7 Days)
- 0.1.0
54
Package Sidebar
Install
Weekly Downloads