treat-as-promise
v1.0.2
Published
Allows treating any variable an (already resolved) promise
Downloads
2
Readme
Allows treating any variable as a promise. Useful if you want to conform to an asynchronous spec. If argument to treatAsPromise is already a promise, treatAsPromise will simply return the promise, so you can treat asynchronous / synchronous returned values in the same way
var treatAsPromise = require('treat-as-promise');
function getData() {
// One day this will be returned from a server asynchronously!
var data = { stuff: 'things' };
return treatAsPromise(data);
}
getData()
.then(function(data) {
console.log(data); // { stuff: 'things' }
});