tiny-defer
v2.0.2
Published
Tiny Deferred for Client or Server
Downloads
16
Maintainers
Readme
tiny-defer
Tiny Deferred for Client or Server
Example
var deferred = require('tiny-defer');
function something () {
var defer = deferred();
setTimeout(function () {
defer.resolve(true);
}, 1000);
return defer.promise;
}
something().then(function (arg) {
console.log(arg); // true;
});
API
promise
Promise
to pass/return
reject()
Rejects the Promise
resolve()
Resolves the Promise
How to use tiny-defer
tiny-defer
can be loaded as a CommonJS or AMD module, or with a script tag which would create window.deferred
.
License
Copyright (c) 2015 Jason Mulligan Licensed under the BSD-3 license