then.js 253 B

12345678910
  1. var Gun = require('./sea').Gun;
  2. Gun.chain.then = function(cb, opt = {}){
  3. opt = {wait: 200, ...opt}
  4. var gun = this, p = (new Promise(function(res, rej){
  5. gun.once(res, opt);
  6. }));
  7. return cb? p.then(cb) : p;
  8. }