Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if(data instanceof Function){
return travel(data, a, b, this);
}
var gun = this, root = gun.back(-1);
var cb = (a instanceof Function && a) || (b instanceof Function && b);
if(Gun.is(data)){
data.get(function(soul){
if(!soul){
return cb && cb({err: "Timegraph cannot link `undefined`!"});
}
gun.time(Gun.val.link.ify(soul), a, b);
}, true);
return gun;
}
opt = (cb === a)? b : a;
opt = Gun.text.is(opt)? {key: opt} : opt || {};
var t = new Date(Gun.state()).toISOString().split(/[\-t\:\.z]/ig);
var p, tmp = t.pop();
gun.get(function(soul){
var id = soul;
p = id;
if(!p){ id = p = (gun.back('opt.uuid') || Gun.text.random)(9) }
// could shrink this into a loop. Do later?
t = [p].concat(t);
var rid = opt.key || (gun.back('opt.uuid') || Gun.text.random)(9);
var milli = ify({}, t.join(':'));
milli[rid] = data;
tmp = t.pop();
var sec = ify({}, t.join(':'));
sec[tmp] = milli;
tmp = t.pop();
var min = ify({}, t.join(':'));
/*jslint node: true*/
var Gun = require('gun/gun');
var Emitter = require('events');
// local data interface
window.local = module.exports = {
db: new Gun({
rtc: false
}),
ID: Gun.text.random(),
events: new Emitter()
};
gun.get(function(soul){
var id = soul;
p = id;
if(!p){ id = p = (gun.back('opt.uuid') || Gun.text.random)(9) }
// could shrink this into a loop. Do later?
t = [p].concat(t);
var rid = opt.key || (gun.back('opt.uuid') || Gun.text.random)(9);
var milli = ify({}, t.join(':'));
milli[rid] = data;
tmp = t.pop();
var sec = ify({}, t.join(':'));
sec[tmp] = milli;
tmp = t.pop();
var min = ify({}, t.join(':'));
min[tmp] = sec;
tmp = t.pop();
var hour = ify({}, t.join(':'));
hour[tmp] = min;
tmp = t.pop();
var day = ify({}, t.join(':'));
function handleSignal(signal) {
var obj, SDO = JSON.stringify(signal);
obj = {};
filter(SDO);
// post the session object
obj[Gun.text.random(10)] = SDO;
peer.path(myID).put(obj);
}
module.exports = function (lex, cb, opt) {
opt = {};
var requestID = Gun.text.random(20);
local.db.__.opt.wire.get(lex, cb, opt);
// when calling `.put`, the raw `.get` driver responds
// with more data causing it to infinitely recurse.
// support options for server stuns.
emitter.on(requestID, function (data) {
cb(data.err, data.value);
});
// be more verbose until we have
// Gun.is.lex, cuz I'm lazy :P
peers.online.broadcast({
RID: requestID,
event: 'get',
lex: lex,
add() {
if (this.newTodo) {
this.todos.get(Gun.text.random()).put(this.newTodo);
this.newTodo = '';
}
}
function handleSignal(signal) {
var SDO = JSON.stringify(signal);
filter(SDO);
requests.path(Gun.text.random(10)).put(SDO);
}
add() {
if (this.newTodo) {
this.todos.path(Gun.text.random()).put(this.newTodo);
this.newTodo = '';
}
}
}
module.exports = function () {
token = Gun.text.random();
return waiting.path(token).put(token);
};
module.exports = function (graph, cb, opt) {
opt = {};
var requestID = Gun.text.random(20);
// Gun.is.graph(graph, function (node, soul) {
// var graph = local.db.__.graph;
// if (!graph[soul]) {
// graph[soul] = node;
// }
// });
// local.db.__.opt.wire.put(graph, cb, opt);
Gun.is.graph(graph, function (node, soul) {
local.db.put(node).key(soul);
});
events.on(requestID, function (data) {
cb(data.err, data.value);
});