Merge pull request #902 from bluelovers/pr/003

fix: bug when import 'lib/then'
This commit is contained in:
Mark Nadal 2020-02-11 14:52:55 -08:00 committed by GitHub
commit 4137c52598
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,11 +11,12 @@ Gun.chain.promise = function(cb) {
};
// Returns a promise for the data, key of the gun call
Gun.chain.then = function() {
Gun.chain.then = function(cb) {
var gun = this;
return (new Promise((res, rej)=>{
var p = (new Promise((res, rej)=>{
gun.once(function (data, key) {
res(data, key); //call resolve when data is returned
})
}))
return cb ? p.then(cb) : p;
};