forget.js 462 B

123456789101112131415161718192021
  1. ;(function(){
  2. var Gun = (typeof window !== "undefined")? window.Gun : require('../gun');
  3. Gun.on('opt', function(root){
  4. once(root);
  5. this.to.next(root);
  6. });
  7. function once(root){
  8. if(root.once){ return }
  9. var forget = root.opt.forget = root.opt.forget || {};
  10. root.on('put', function(msg){
  11. Gun.graph.is(msg.put, function(node, soul){
  12. if(!Gun.obj.has(forget, soul)){ return }
  13. delete msg.put[soul];
  14. });
  15. this.to.next(msg);
  16. });
  17. }
  18. }());