Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return this.once((obj: object = {}, key: string) => {
// if null or undefined (but shouldnt be able to be that, right ?).. skip it if opt allows
if (obj === null) {
return;
}
const { _: obSoul, ...obRest } = Gun.obj.copy(obj);
obj = obRest;
// next objects to dig into
const queue: any = {};
// current doc (passed on the callback)
let doc: object;
// flag
let done: boolean;
// get deeper into the reference soul
const expand = (newObj: object | any = {}) => {
const { _: newObSoul, ...o } = newObj;
// console.log("que", queue);
// if doc is null assign the current object to the doc
if (!doc) {
doc = o;
module.exports = function find(player) {
var coord, position;
coord = sort(player);
coord = coord[coord.length - 1];
// if the player has no history
if (!coord) {
return null;
}
// don't mutate the last position, make a copy
position = Gun.obj.copy(coord);
position[coord.axis] = distance(coord);
position.time = Gun.time.is();
return position;
};
function collision() {
var lines = [];
// add every player's history to the list of lines
Gun.obj.map(players.list, function (player, number) {
var history = path(player);
lines = lines.concat(history);
});
/*
Filter out lines that aren't dangerous,
then filter out the ones that aren't in
your way, then filter out the ones you're
not overlapping with.
*/
return lines.filter(function (line) {
return line.axis !== position.axis;
}).filter(inPath).filter(crossing).length;
}
}, opt.wait || 1);
opt.at = opt.at || ctx;
opt.key = opt.key || key;
// @ts-ignore
opt.ev.s[this._.id] = ev;
if(Gun.val.is(data)){
if(!at){
opt.doc = data;
} else {
at[key] = data;
}
return;
}
// @ts-ignore
var tmp = this, id;
Gun.obj.map(data, function(val: object, key: string){
if(!(id = Gun.val.link.is(val))){
(at || opt.doc)[key] = val;
return;
}
if(opt.ids[id]){
(at || opt.doc)[key] = opt.ids[id];
return;
}
tmp.get(key).docSubscribe(opt.any, opt, opt.ids[id] = (at || opt.doc)[key] = {});
});
})
}
const union = function union(vertex, node, opt){
if(!node || !node._){ return }
vertex = vertex || Gun.state.to(node);
if(!vertex || !vertex._){ return }
opt = Gun.num.is(opt)? {machine: opt} : {machine: Gun.state()};
opt.union = Gun.obj.copy(vertex); // Slow performance.
if(!Gun.node.is(node, function(val, key){
var HAM = Gun.HAM(opt.machine, Gun.state.is(node, key), Gun.state.is(vertex, key, true), val, vertex[key]);
if(!HAM.incoming){ return }
Gun.state.to(node, key, opt.union);
})){ return }
return opt.union;
}
/* eslint-enable */
setInterval(function () {
Gun.obj.map(game.players, function (player, number) {
if (!player) {
return;
}
if (expired(player)) {
console.log('Kicking player', number);
game.db.path(number).put(null);
}
});
}, 1000);
opt.ev = opt.ev || {off: function(){
Gun.obj.map(opt.ev.s, function(e: any){
if(e){ e.off() }
});
opt.ev.s = {};
}, s:{}}
return this.on(function(data: any, key: string, ctx: any, ev: any){
store.Record.upsert(id, data).then(function(){
Gun.obj.del(block, id);
Gun.obj.del(block, soul);
check[id] = false;
if(Gun.obj.map(check, function(val){
if(val){ return true }
})){ return }
gun.on('in', {'@': at['#'], ok: 1});
}, function(e){
if(e && e.toString().indexOf('UNIQUE') >= 0){
root.get(soul).once((loadedValue: object) => {
loadedValue = Gun.obj.copy(loadedValue);
o[k] = loadedValue;
queue[soul] = false;
expand(loadedValue);
}, {wait: 200});
return;
store.Record.upsert(id, data).then(function(){
Gun.obj.del(block, id);
Gun.obj.del(block, soul);
check[id] = false;
if(Gun.obj.map(check, function(val){
if(val){ return true }
})){ return }
gun.on('in', {'@': at['#'], ok: 1});
}, function(e){
if(e && e.toString().indexOf('UNIQUE') >= 0){