Merge pull request #451 from d3x0r/unset-addon

Add utility chain function to remove items from a set.
This commit is contained in:
Mark Nadal 2017-11-05 14:38:38 -08:00 committed by GitHub
commit ab196bc42f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

14
lib/unset.js Normal file
View File

@ -0,0 +1,14 @@
if(typeof window !== "undefined"){
var Gun = window.Gun;
} else {
var Gun = require('gun/gun');
}
const rel_ = Gun.val.rel._; // '#'
const node_ = Gun.node._; // '_'
Gun.chain.unset = function(node){
if( this && node && node[node_] && node[node_].put && node[node_].put[node_] && node[node_].put[node_][rel_] )
this.put( { [node[node_].put[node_][rel_]]:null} );
return this;
}