gun/lib/promise.js
2017-08-31 17:53:55 -04:00

11 lines
299 B
JavaScript

var Gun = Gun || require('../gun');
Gun.chain.promise = function(cb) {
var gun = this, cb = cb || function(ctx) { return ctx };
return (new Promise(function(res, rej) {
gun.val(function(node, key) {
res({val: node, key: key, gun: gun});
});
})).then(cb);
};