Promish
SH
I
P R O M
The Promish module creates a wrapper around the EcmaScript 6 Promise class.
It adds some of the useful features found in many of the other popular promise libraries such as Q and Bluebird.
It is designed to be interchangeable with the ES6 Promise as its interface is a superset of the Promise class.
Installation
npm install promish
New Features!
Backlog
Contents
Interface
Include
var Promish = require('promish');
Instantiation
Typical use - construct with handler function
var promise = new Promish(function(resolve, reject) {
});
3rd Party Wrapper Mode
var promise = new Promish(Q());
Value Wrapper Mode
var promise = new Promish('Resolve Value');
Error Wrapper Mode
var promise = new Promish(new Error('This promise is rejected'));
Then
promise
.then(function(value) {
});
promise.then(
function(value) {
},
function(error) {
});
Catch
promise
.catch(function(error) {
});
Defer
For compatability with the old Promise.defer() pattern...
function readAFile(filename) {
var deferred = Promish.defer();
fs.readFile(filename, function(error, data) {
if (error) {
deferred.reject(error);
} else {
deferred.resolve(data);
}
});
return deferred.promise;
}
Known Issues
Release History