From 16f911e126d69cecc2d98a7fbdea2bd1bd9b4c47 Mon Sep 17 00:00:00 2001 From: bluelovers Date: Thu, 6 Feb 2020 20:54:42 +0800 Subject: [PATCH] fix: bug when import 'lib/then' --- lib/then.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/then.js b/lib/then.js index 731454a8..85d32116 100644 --- a/lib/then.js +++ b/lib/then.js @@ -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; };