mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
hardest thing is naming and off by one
This commit is contained in:
parent
353e622ff9
commit
06ff44a865
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "gun",
|
||||
"main": "gun.js",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"homepage": "http://gunDB.io",
|
||||
"authors": [
|
||||
{ "name": "Mark Nadal", "email": "mark@accelsor.com" },
|
||||
|
@ -8,7 +8,7 @@
|
||||
}
|
||||
, "dependencies": {
|
||||
"express": "~>4.9.0",
|
||||
"gun": "0.1.2"
|
||||
"gun": "0.1.3"
|
||||
}
|
||||
, "scripts": {
|
||||
"start": "node express.js",
|
||||
|
18
gun.js
18
gun.js
@ -351,14 +351,14 @@
|
||||
next(); // continue with the chain.
|
||||
cb = cb || function(){}; // fail safe our function.
|
||||
if(!gun._.node){ return } // if no node, then abandon and let blank handle it.
|
||||
var field = gun._.field, val = gun._.node[field]; // else attempt to get the value at the field, if we have a field.
|
||||
var field = Gun.text.ify(gun._.field), val = gun._.node[field]; // else attempt to get the value at the field, if we have a field.
|
||||
if(field && Gun.is.soul(val)){ // if we have a field, then check to see if it is a relation
|
||||
return gun.load(val, function(err, val){ // and load it.
|
||||
return gun.load(val, function(err, value){ // and load it.
|
||||
if(err || !this._.node){ return } // handle error?
|
||||
cb.call(this, val, field); // already frozen copy
|
||||
cb.call(this, value, field); // already frozen copy
|
||||
});
|
||||
}
|
||||
cb.call(gun, gun._.field? Gun.is.value.as(val) : Gun.obj.copy(gun._.node), gun._.field); // frozen copy
|
||||
cb.call(gun, field? Gun.is.value.as(val) : Gun.obj.copy(gun._.node), field); // frozen copy
|
||||
});
|
||||
return gun;
|
||||
}
|
||||
@ -368,13 +368,14 @@
|
||||
cb = cb || function(){}; // fail safe our function.
|
||||
cb.call(gun, val, field);
|
||||
gun.__.on(Gun.is.soul.on(gun._.node)).event(function(delta){ // then subscribe to subsequent changes.
|
||||
field = Gun.text.ify(gun._.field);
|
||||
if(!delta || !gun._.node){ return }
|
||||
if(!gun._.field){ // if we were listening to changes on the node as a whole
|
||||
if(!field){ // if we were listening to changes on the node as a whole
|
||||
return cb.call(gun, Gun.obj.copy(gun._.node)); // frozen copy
|
||||
}
|
||||
if(Gun.obj.has(delta, gun._.field)){ // else changes on an individual property
|
||||
delta = delta[gun._.field]; // grab it and
|
||||
cb.call(gun, Gun.obj.is(delta)? Gun.obj.copy(delta) : Gun.is.value.as(delta), gun._.field); // frozen copy
|
||||
if(Gun.obj.has(delta, field)){ // else changes on an individual property
|
||||
delta = delta[field]; // grab it and
|
||||
cb.call(gun, Gun.obj.is(delta)? Gun.obj.copy(delta) : Gun.is.value.as(delta), field); // frozen copy
|
||||
// TODO! BUG: If delta is an object, that would suggest it is a relation which needs to get loaded.
|
||||
}
|
||||
});
|
||||
@ -400,6 +401,7 @@
|
||||
gun.shot.next(function(next){
|
||||
opt = opt || {};
|
||||
cb = cb || function(){};
|
||||
gun._.field = Gun.text.ify(field);
|
||||
if(!gun._.node){
|
||||
if(Gun.is.value(val) || !Gun.obj.is(val)){
|
||||
return cb.call(gun, {err: Gun.log("No field exists to set the " + (typeof val) + " on.")});
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gun",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"author": "Mark Nadal",
|
||||
"description": "Graph engine.",
|
||||
"engines": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user