mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
Merge branch 'sea' into sea
This commit is contained in:
commit
8669d63879
1
Procfile
Normal file
1
Procfile
Normal file
@ -0,0 +1 @@
|
||||
web: node --optimize_for_size --max_old_space_size=460 --gc_interval=100 examples/http.js
|
@ -85,6 +85,10 @@ ul, li {
|
||||
.rim {
|
||||
margin: 2%;
|
||||
}
|
||||
.gap {
|
||||
padding: 3%;
|
||||
}
|
||||
|
||||
.loud {
|
||||
font-size: 150%;
|
||||
}
|
||||
|
45
lib/untitled
45
lib/untitled
@ -1,45 +0,0 @@
|
||||
;(function(exports){ // On event emitter generic javascript utility.
|
||||
function On(){ var on = this;
|
||||
if(!On.is(on)){ return new On() }
|
||||
return function(e, fn, i){ return on.e = e, fn? on.event(fn, i) : on };
|
||||
};
|
||||
On.is = function(on){ return (on instanceof On) }
|
||||
On.chain = On.prototype;
|
||||
On.chain.create = function(){ return On.call(null) }
|
||||
var on = function(e){
|
||||
on.event.e = e;
|
||||
on.event.s[e] = on.event.s[e] || [];
|
||||
return on;
|
||||
};
|
||||
On.chain.emit = function(a,b,c,d){
|
||||
var on = this, e = on.e, s = on.s[e];
|
||||
exports.list.map(s, function(at, i){ at.on(a,b,c,d) });
|
||||
if(s && !s.length){ delete on.s[e] }
|
||||
}
|
||||
function At(fn, i){ var at = this;
|
||||
if(!At.is(at)){ return new At() }
|
||||
at.on = fn;
|
||||
at.i = i; // TODO: MARK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! COME BACK HERE!
|
||||
};
|
||||
At.is = function(at){ return (at instanceof At) }
|
||||
On.chain = On.prototype;
|
||||
On.chain.event = function(fn, i){
|
||||
//on.event = function(fn, i){
|
||||
var on = this, e = on.e, s = on.s[e] = on.s[e] || [], at = At(fn, i);
|
||||
var e = {fn: fn, i: i || 0, off: function(){ return !(e.fn = false) }}; // TODO: PERFORMANCE! Prototype-ify this and reduce any on complexity.
|
||||
return s.push(e), i? s.sort(sort) : i, e;
|
||||
}
|
||||
//on.event.s = {};
|
||||
//return on;
|
||||
|
||||
var sort = exports.list.sort('i');
|
||||
exports.on = On; //On();
|
||||
}(Gun || {}));
|
||||
|
||||
|
||||
/*
|
||||
on('foo', function(){
|
||||
|
||||
})
|
||||
|
||||
on('foo').emit('yay');*/
|
43
test/ptsd/spam.js
Normal file
43
test/ptsd/spam.js
Normal file
@ -0,0 +1,43 @@
|
||||
;(function(){
|
||||
window.SPAM = function(cb, opt){
|
||||
opt = Gun.num.is(opt)? {each: opt} : opt || {};
|
||||
setInterval(burst, opt.wait);
|
||||
|
||||
var n = Gun.time.is(), i = 0, c = 0, b = opt.burst || 1, l = opt.each || 100;
|
||||
var raw = "AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA AAAAA "
|
||||
|
||||
function save(i){
|
||||
if(!window.SPAM){ return }
|
||||
if(i > l){
|
||||
return clearTimeout(t);
|
||||
}
|
||||
cb(i, raw + i);
|
||||
return;
|
||||
var d;
|
||||
var ref = window.gun.get('asdf'+i);
|
||||
ref.put({hello: raw + i}, function(ack){
|
||||
if(d){ return } d = true;
|
||||
c++;
|
||||
!(i % b) && console.log(i+'/'+l);//, '@'+Math.floor(b/((-n + (n = Gun.time.is()))/1000))+'/sec');
|
||||
//localStorage.clear();
|
||||
ref.off();
|
||||
//console.log("gl:", Object.keys(window.gun._.graph).length);
|
||||
if(c < l){ return }
|
||||
setTimeout(function(){
|
||||
test.done();
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
function burst(){
|
||||
for(var j = 0; j <= b; j++){
|
||||
save(++i);
|
||||
}
|
||||
}
|
||||
var t;
|
||||
}
|
||||
}());
|
||||
|
||||
SPAM(function(i, v){
|
||||
$("#message-input").text(v);
|
||||
$('.say').trigger('click');
|
||||
}, 10000);
|
@ -17,6 +17,7 @@
|
||||
<script src="../examples/jquery.js"></script>
|
||||
<script src="../gun.js"></script>
|
||||
<script src="../sea.js"></script>
|
||||
<script src="../lib/then.js"></script>
|
||||
|
||||
<script>
|
||||
var gun = Gun();
|
||||
|
50
untitled.js
50
untitled.js
@ -1,50 +0,0 @@
|
||||
function input(msg){
|
||||
var ev = this, cat = this.as, gun = msg.gun, at = gun._, change = msg.put, rel, tmp;
|
||||
// dispatch to chain listeners.
|
||||
// dispatch to children.
|
||||
// dispatch to echoes.
|
||||
if(u === change){
|
||||
// Here are the possible options:
|
||||
// 1. We think the data does not exist because peers/disk cannot find it.
|
||||
// 2. We know the data does not exist because a parent is or was changed to a primitive.
|
||||
// Souls can only (1) because they have no parent.
|
||||
// Has can be (1) or (2).
|
||||
// Gets and chains can be (1) or (2).
|
||||
if(cat.soul || cat.has){
|
||||
// a soul can never become undefined.
|
||||
// a soul can only not be found.
|
||||
if(cat.soul && u !== cat.put){
|
||||
return;
|
||||
}
|
||||
// a key may sometimes might not be found.
|
||||
// a key on a soul can not become undefined,
|
||||
// but the chain might be on a chain that
|
||||
// does not exist, and therefore can be undefined.
|
||||
ev.to.next(msg); // ex, notify val and stuff.
|
||||
echo(cat, msg, ev); // ex, notify a sub-object pointer like `mark.pet`! // TODO: BUG ON VAL, it will still not get called because it checks !node when it should also check ack.
|
||||
if(cat.soul){ return }
|
||||
obj_map(cat.next, unknown); // notify children.
|
||||
}
|
||||
if(cat.has){
|
||||
if()
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(cat.soul){
|
||||
return;
|
||||
}
|
||||
if(cat.has){
|
||||
return;
|
||||
}
|
||||
if(cat.get){
|
||||
return;
|
||||
}
|
||||
ev.to.next(msg);
|
||||
}
|
||||
|
||||
function unknown(ref, key){
|
||||
(ref = (ref._)).put = u;
|
||||
ref.on('in', {get: key, put: u, gun: ref.gun});
|
||||
}
|
||||
|
||||
gun.get('users').map().map().get('who').get('say').map().on(cb);
|
Loading…
x
Reference in New Issue
Block a user