Use console.warn and console.error

This commit is contained in:
Anton 2023-08-21 10:17:36 +02:00
parent f882b86889
commit 4d26c4035e
47 changed files with 149 additions and 132 deletions

4
as.js
View File

@ -211,7 +211,7 @@
$.as.route(location.hash.slice(1));
$(JOY.start = JOY.start || function(){ $.as(document, gun, null, JOY.opt) });
if($('body').attr('peers')){ (console.warn || console.log)('Warning: Please upgrade <body peers=""> to https://github.com/eraeco/joydb#peers !') }
if($('body').attr('peers')){ console.warn('Please upgrade <body peers=""> to https://github.com/eraeco/joydb#peers !') }
});
;(function(){ // need to isolate into separate module!
@ -228,7 +228,7 @@
var opt = joy.opt = window.CONFIG || {}, peers;
$('link[type=peer]').each(function(){ (peers || (peers = [])).push($(this).attr('href')) });
!window.gun && (opt.peers = opt.peers || peers || (function(){
(console.warn || console.log)('Warning: No peer provided, defaulting to DEMO peer. Do not run in production, or your data will be regularly wiped, reset, or deleted. For more info, check https://github.com/eraeco/joydb#peers !');
console.warn('No peer provided, defaulting to DEMO peer. Do not run in production, or your data will be regularly wiped, reset, or deleted. For more info, check https://github.com/eraeco/joydb#peers !');
return ['https://gunjs.herokuapp.com/gun'];
}()));
window.gun = window.gun || Gun(opt);

2
axe.js
View File

@ -27,7 +27,7 @@
tmp = peers[id = 'http://localhost:8765/gun'] = peers[id] || {};
tmp.id = tmp.url = id; tmp.retry = tmp.retry || 0;
Gun.log.once("AXE", "AXE enabled: Trying to find network via (1) local peer (2) last used peers (3) a URL parameter, and last (4) hard coded peers.");
Gun.log.once("AXEWarn", "Warning: AXE is in alpha, use only for testing!");
Gun.warn.once("AXEWarn", "AXE is in alpha, use only for testing!");
var last = lS.peers || ''; if(last){ last += ' ' }
last += ((loc.search||'').split('peers=')[1]||'').split('&')[0];

View File

@ -42,7 +42,7 @@ if (!isElectron && ('serviceWorker' in navigator)) {
navigator.serviceWorker.register('iris/serviceworker.js')
.catch(function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
console.warn('ServiceWorker registration failed: ', err);
});
});
}

View File

@ -894,7 +894,7 @@
(cb || noop)({ok: 0});
});
} catch (e) {
Gun.log('User.delete failed! Error:', e);
Gun.error('User.delete failed! Error:', e);
}
return gun;
}

View File

@ -37,7 +37,7 @@
record.ing.start()
}
function error(err) { console.log(err) }
function error(err) { console.error(err) }
if (type === 'Camera') {
navigator.getMedia({ video: true, audio: true }, load, error)

34
gun.js
View File

@ -436,7 +436,7 @@
var ERR = "Error: Invalid graph!";
var cut = function(s){ return " '"+(''+s).slice(0,9)+"...' " }
var L = JSON.stringify, MD = 2147483647, State = Gun.state;
var C = 0, CT, CF = function(){if(C>999 && (C/-(CT - (CT = +new Date))>1)){Gun.window && console.log("Warning: You're syncing 1K+ records a second, faster than DOM can update - consider limiting query.");CF=function(){C=0}}};
var C = 0, CT, CF = function(){if(C>999 && (C/-(CT - (CT = +new Date))>1)){Gun.window && console.warn("You're syncing 1K+ records a second, faster than DOM can update - consider limiting query.");CF=function(){C=0}}};
}());
@ -540,7 +540,11 @@
var obj_each = function(o,f){ Object.keys(o).forEach(f,o) }, text_rand = String.random, turn = setTimeout.turn, valid = Gun.valid, state_is = Gun.state.is, state_ify = Gun.state.ify, u, empty = {}, C;
Gun.log = function(){ return (!Gun.log.off && C.log.apply(C, arguments)), [].slice.call(arguments).join(' ') };
Gun.warn = function(){ return (!Gun.log.off && !Gun.warn.off && C.warn.apply(C, arguments)), [].slice.call(arguments).join(' ') };
Gun.error = function(){ return (!Gun.log.off && !Gun.error.off && C.error.apply(C, arguments)), [].slice.call(arguments).join(' ') };
Gun.log.once = function(w,s,o){ return (o = Gun.log.once)[w] = o[w] || 0, o[w]++ || Gun.log(s) };
Gun.warn.once = function(w,s,o){ return (o = Gun.warn.once)[w] = o[w] || 0, o[w]++ || Gun.warn(s) };
Gun.error.once = function(w,s,o){ return (o = Gun.error.once)[w] = o[w] || 0, o[w]++ || Gun.error(s) };
if(typeof window !== "undefined"){ (window.GUN = window.Gun = Gun).window = window }
try{ if(typeof MODULE !== "undefined"){ MODULE.exports = Gun } }catch(e){}
@ -696,7 +700,7 @@
var root = cat.root, gun = msg.$ || (msg.$ = cat.$), at = (gun||'')._ || empty, tmp = msg.put||'', soul = tmp['#'], key = tmp['.'], change = (u !== tmp['='])? tmp['='] : tmp[':'], state = tmp['>'] || -Infinity, sat; // eve = event, at = data at, cat = chain at, sat = sub at (children chains).
if(u !== msg.put && (u === tmp['#'] || u === tmp['.'] || (u === tmp[':'] && u === tmp['=']) || u === tmp['>'])){ // convert from old format
if(!valid(tmp)){
if(!(soul = ((tmp||'')._||'')['#'])){ console.log("chain not yet supported for", tmp, '...', msg, cat); return; }
if(!(soul = ((tmp||'')._||'')['#'])){ console.warn("chain not yet supported for", tmp, '...', msg, cat); return; }
gun = cat.root.$.get(soul);
return setTimeout.each(Object.keys(tmp).sort(), function(k){ // TODO: .keys( is slow // BUG? ?Some re-in logic may depend on this being sync?
if('_' == k || u === (state = state_is(tmp, k))){ return }
@ -852,7 +856,7 @@
var gun, tmp;
if(typeof key === 'string'){
if(key.length == 0) {
(gun = this.chain())._.err = {err: Gun.log('0 length key!', key)};
(gun = this.chain())._.err = {err: Gun.warn('0 length key!', key)};
if(cb){ cb.call(gun, gun._.err) }
return gun;
}
@ -943,7 +947,7 @@
gun = tmp(this, key);
}
if(!gun){
(gun = this.chain())._.err = {err: Gun.log('Invalid get request!', key)}; // CLEAN UP
(gun = this.chain())._.err = {err: Gun.warn('Invalid get request!', key)}; // CLEAN UP
if(cb){ cb.call(gun, gun._.err) }
return gun;
}
@ -1254,7 +1258,7 @@
return gun;
}
function none(gun,opt,chain){
Gun.log.once("valonce", "Chainable val is experimental, its behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it.");
Gun.warn.once("valonce", "Chainable val is experimental, its behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it.");
(chain = gun.chain())._.nix = gun.once(function(data, key){ chain._.on('in', this._) });
chain._.lex = gun._.lex; // TODO: Better approach in future? This is quick for now.
return chain;
@ -1329,7 +1333,7 @@
gun.on('in', map, chain._);
return chain;
}
Gun.log.once("mapfn", "Map functions are experimental, their behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it.");
Gun.warn.once("mapfn", "Map functions are experimental, their behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it.");
chain = gun.chain();
gun.map().on(function(data, key, msg, eve){
var next = (cb||noop).call(this, data, key, msg, eve);
@ -1366,7 +1370,7 @@
}
gun.put(function(go){
item.get(function(soul, o, msg){ // TODO: BUG! We no longer have this option? & go error not handled?
if(!soul){ return cb.call(gun, {err: Gun.log('Only a node can be linked! Not "' + msg.put + '"!')}) }
if(!soul){ return cb.call(gun, {err: Gun.warn('Only a node can be linked! Not "' + msg.put + '"!')}) }
(tmp = {})[soul] = {'#': soul}; go(tmp);
},true);
})
@ -1380,12 +1384,14 @@
var noop = function(){}
var parse = JSON.parseAsync || function(t,cb,r){ var u, d = +new Date; try{ cb(u, JSON.parse(t,r), json.sucks(+new Date - d)) }catch(e){ cb(e) } }
var json = JSON.stringifyAsync || function(v,cb,r,s){ var u, d = +new Date; try{ cb(u, JSON.stringify(v,r,s), json.sucks(+new Date - d)) }catch(e){ cb(e) } }
json.sucks = function(d){ if(d > 99){ console.log("Warning: JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."); json.sucks = noop } }
json.sucks = function(d){ if(d > 99){ console.warn("JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."); json.sucks = noop } }
function Mesh(root){
var mesh = function(){};
var opt = root.opt || {};
opt.log = opt.log || console.log;
opt.warn = opt.warn || console.warn;
opt.error = opt.error || console.error;
opt.gap = opt.gap || opt.wait || 0;
opt.max = opt.max || (opt.memory? (opt.memory * 999 * 999) : 300000000) * 0.3;
opt.pack = opt.pack || (opt.max * 0.01 * 0.01);
@ -1619,7 +1625,7 @@
if(!tmp){ return }
if(t? 3 > tmp.length : !tmp.length){ return } // TODO: ^
if(!t){try{tmp = (1 === tmp.length? tmp[0] : JSON.stringify(tmp));
}catch(e){return opt.log('DAM JSON stringify error', e)}}
}catch(e){return opt.error('DAM JSON stringify error', e)}}
if(!tmp){ return }
send(tmp, peer);
}
@ -1667,7 +1673,7 @@
var tmp = +(new Date); tmp = (tmp - (peer.met||tmp));
mesh.bye.time = ((mesh.bye.time || tmp) + tmp) / 2;
}
mesh.hear['!'] = function(msg, peer){ opt.log('Error:', msg.err) }
mesh.hear['!'] = function(msg, peer){ opt.error('Error:', msg.err) }
mesh.hear['?'] = function(msg, peer){
if(msg.pid){
if(!peer.pid){ peer.pid = msg.pid }
@ -1708,7 +1714,7 @@
if(tmp = console.STAT){ tmp.peers = mesh.near }
if(opt.super){ return } // temporary (?) until we have better fix/solution?
var souls = Object.keys(root.next||''); // TODO: .keys( is slow
if(souls.length > 9999 && !console.SUBS){ console.log(console.SUBS = "Warning: You have more than 10K live GETs, which might use more bandwidth than your screen can show - consider `.off()`.") }
if(souls.length > 9999 && !console.SUBS){ console.warn(console.SUBS = "You have more than 10K live GETs, which might use more bandwidth than your screen can show - consider `.off()`.") }
setTimeout.each(souls, function(soul){ var node = root.next[soul];
if(opt.super || (node.ask||'')['']){ mesh.say({get: {'#': soul}}, peer); return }
setTimeout.each(Object.keys(node.ask||''), function(key){ if(!key){ return }
@ -1794,7 +1800,7 @@
var noop = function(){}, store, u;
try{store = (Gun.window||noop).localStorage}catch(e){}
if(!store){
Gun.log("Warning: No localStorage exists to persist data to!");
Gun.warn("No localStorage exists to persist data to!");
store = {setItem: function(k,v){this[k]=v}, removeItem: function(k){delete this[k]}, getItem: function(k){return this[k]}};
}
@ -1841,7 +1847,7 @@
try{!err && store.setItem(opt.prefix, tmp);
}catch(e){ err = stop = e || "localStorage failure" }
if(err){
Gun.log(err + " Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install");
Gun.error(err + " Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install");
root.on('localStorage:error', {err: err, get: opt.prefix, put: disk});
}
size = tmp.length;
@ -1862,7 +1868,7 @@
;(function(){
var u;
if(''+u == typeof Gun){ return }
var DEP = function(n){ console.warn("Warning! Deprecated internal utility will break in next version:", n) }
var DEP = function(n){ console.warn("Deprecated internal utility will break in next version:", n) }
// Generic javascript utilities.
var Type = Gun;
//Type.fns = Type.fn = {is: function(fn){ return (!!fn && fn instanceof Function) }}

2
gun.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
;(function(){ // Book
console.log("Warning: Book is in alpha!");
console.warn("Book is in alpha!");
var sT = setTimeout, B = sT.Book || (sT.Book = function(text){
var b = function book(word, is){
var has = b.all[word], p;

View File

@ -19,9 +19,9 @@ Gun.on('create', function(root){
fs.readFileSync(opt.file).toString()
: null) || {};
Gun.log.once(
Gun.warn.once(
'file-warning',
'WARNING! This `file.js` module for gun is ' +
'This `file.js` module for gun is ' +
'intended for local development testing only!'
);

View File

@ -4,6 +4,8 @@
opt = opt || {};
opt.log = opt.log || console.log;
opt.warn = opt.warn || console.warn;
opt.error = opt.error || console.error;
opt.file = String(opt.file || 'radata');
var has = (Radisk.has || (Radisk.has = {}))[opt.file];
if(has){ return has }
@ -25,16 +27,16 @@
var ST = 0;
if(!opt.store){
return opt.log("ERROR: Radisk needs `opt.store` interface with `{get: fn, put: fn (, list: fn)}`!");
return opt.error("Radisk needs `opt.store` interface with `{get: fn, put: fn (, list: fn)}`!");
}
if(!opt.store.put){
return opt.log("ERROR: Radisk needs `store.put` interface with `(file, data, cb)`!");
return opt.error("Radisk needs `store.put` interface with `(file, data, cb)`!");
}
if(!opt.store.get){
return opt.log("ERROR: Radisk needs `store.get` interface with `(file, cb)`!");
return opt.error("Radisk needs `store.get` interface with `(file, cb)`!");
}
if(!opt.store.list){
//opt.log("WARNING: `store.list` interface might be needed!");
//opt.warn("`store.list` interface might be needed!");
}
if(''+u != typeof require){ require('./yson') }

View File

@ -5,6 +5,8 @@
opt = opt || {};
opt.log = opt.log || console.log;
opt.warn = opt.warn || console.warn;
opt.error = opt.error || console.error;
opt.file = String(opt.file || 'radata');
var has = (Radisk.has || (Radisk.has = {}))[opt.file];
if(has){ return has }
@ -23,16 +25,16 @@
var LOG = false;
if(!opt.store){
return opt.log("ERROR: Radisk needs `opt.store` interface with `{get: fn, put: fn (, list: fn)}`!");
return opt.error("Radisk needs `opt.store` interface with `{get: fn, put: fn (, list: fn)}`!");
}
if(!opt.store.put){
return opt.log("ERROR: Radisk needs `store.put` interface with `(file, data, cb)`!");
return opt.error("Radisk needs `store.put` interface with `(file, data, cb)`!");
}
if(!opt.store.get){
return opt.log("ERROR: Radisk needs `store.get` interface with `(file, cb)`!");
return opt.error("Radisk needs `store.get` interface with `(file, cb)`!");
}
if(!opt.store.list){
//opt.log("WARNING: `store.list` interface might be needed!");
//opt.warn("`store.list` interface might be needed!");
}
/*

View File

@ -1,5 +1,5 @@
;(function(){ // RAD
console.log("Warning: Experimental rewrite of RAD to use Book. It is not API compatible with RAD yet and is very alpha.");
console.warn("Experimental rewrite of RAD to use Book. It is not API compatible with RAD yet and is very alpha.");
var sT = setTimeout, Book = sT.Book, RAD = sT.RAD || (sT.RAD = function(opt){
opt = opt || {};
opt.file = String(opt.file || 'radata');

View File

@ -8,7 +8,7 @@ module.exports = function(r){
l.push([f,v]);
});
if(l.length){
console.log("\n! ! ! WARNING ! ! !\nRAD v0.2020.x has detected OLD v0.2019.x data & automatically migrating. Automatic migration will be turned OFF in future versions! If you are just developing/testing, we recommend you reset your data. Please contact us if you have any concerns.\nThis message should only log once.")
console.warn("RAD v0.2020.x has detected OLD v0.2019.x data & automatically migrating. Automatic migration will be turned OFF in future versions! If you are just developing/testing, we recommend you reset your data. Please contact us if you have any concerns.\nThis message should only log once.")
}
var f, v;
l.forEach(function(a){

View File

@ -1,12 +1,13 @@
function Store(opt){
opt = opt || {};
opt.log = opt.log || console.log;
opt.error = opt.error || console.error;
opt.file = String(opt.file || 'radata');
var fs = require('fs'), u;
var store = function Store(){};
if(Store[opt.file]){
console.log("Warning: reusing same fs store and options as 1st.");
console.warn("Reusing same fs store and options as 1st.");
return Store[opt.file];
}
Store[opt.file] = store;
@ -35,7 +36,7 @@ function Store(opt){
if('ENOENT' === (err.code||'').toUpperCase()){
return cb();
}
opt.log("ERROR:", err);
opt.error("ERROR:", err);
}
cb(err, data);
});

View File

@ -16,7 +16,7 @@ if (navigator.storage && navigator.storage.estimate) {
var store = Store[opt.file], db = null, u;
if(store){
console.log("Warning: reusing same IndexedDB store and options as 1st.");
console.warn("Reusing same IndexedDB store and options as 1st.");
return Store[opt.file];
}
store = Store[opt.file] = function(){};
@ -26,7 +26,7 @@ if (navigator.storage && navigator.storage.estimate) {
var s = store.d || (store.d = {});
store.put = function(f, d, cb){ s[f] = d; setTimeout(function(){ cb(null, 1) },250) };
store.get = function(f, cb){ setTimeout(function(){ cb(null, s[f] || u) },5) };
console.log('Warning: No indexedDB exists to persist data to!');
console.warn('No indexedDB exists to persist data to!');
return store;
}}catch(e){}
@ -35,7 +35,7 @@ if (navigator.storage && navigator.storage.estimate) {
var o = indexedDB.open(opt.file, 1);
o.onupgradeneeded = function(eve){ (eve.target.result).createObjectStore(opt.file) }
o.onsuccess = function(){ db = o.result }
o.onerror = function(eve){ console.log(eve||1); }
o.onerror = function(eve){ console.error(eve||1); }
}; store.start();
store.put = function(key, data, cb){

View File

@ -45,7 +45,7 @@ function Store(opt){
var store = function Store(){};
if(Store[opt.file]){
console.log("Warning: reusing same S3 store and options as 1st.");
console.warn("Reusing same S3 store and options as 1st.");
return Store[opt.file];
}
Store[opt.file] = store;

View File

@ -14,7 +14,7 @@
} else {
}
if (!peer.id) {console.log('[*** WARN] no peer.id %s', soul);}
if (!peer.id) {console.warn('No peer.id %s', soul);}
var subs = Gun.subs(soul) || null;
var tmp = subs ? subs.split(',') : [], p = at.opt.peers;
if (subs) {

View File

@ -1,7 +1,7 @@
;(function(){
var u;
if(''+u == typeof Gun){ return }
var DEP = function(n){ console.log("Warning! Deprecated internal utility will break in next version:", n) }
var DEP = function(n){ console.warn("Deprecated internal utility will break in next version:", n) }
// Generic javascript utilities.
var Type = Gun;
//Type.fns = Type.fn = {is: function(fn){ return (!!fn && fn instanceof Function) }}

2
nts.js
View File

@ -4,7 +4,7 @@
var smooth = 2;
Gun.on('create', function(root){ // switch to DAM, deprecated old
Gun.log.once("nts", "gun/nts is removed deprecated old");
Gun.warn.once("nts", "gun/nts is removed deprecated old");
this.to.next(root);
return ; // stub out for now. TODO: IMPORTANT! re-add back in later.
var opt = root.opt, mesh = opt.mesh;

70
sea.js
View File

@ -48,7 +48,7 @@
var u;
if(u+''== typeof btoa){
if(u+'' == typeof Buffer){
try{ global.Buffer = USE("buffer", 1).Buffer }catch(e){ console.log("Please `npm install buffer` or add it to your package.json !") }
try{ global.Buffer = USE("buffer", 1).Buffer }catch(e){ console.warn("Please `npm install buffer` or add it to your package.json !") }
}
global.btoa = function(data){ return Buffer.from(data, "binary").toString("base64") };
global.atob = function(data){ return Buffer.from(data, "base64").toString("binary") };
@ -203,7 +203,7 @@
api.ossl = api.subtle = new WebCrypto({directory: 'ossl'}).subtle // ECDH
}
catch(e){
console.log("Please `npm install @peculiar/webcrypto` or add it to your package.json !");
console.warn("Please `npm install @peculiar/webcrypto` or add it to your package.json !");
}}
module.exports = api
@ -289,7 +289,7 @@
data = (typeof data == 'string')? data : await shim.stringify(data);
if('sha' === (opt.name||'').toLowerCase().slice(0,3)){
var rsha = shim.Buffer.from(await sha(data, opt.name), 'binary').toString(opt.encode || 'base64')
if(cb){ try{ cb(rsha) }catch(e){console.log(e)} }
if(cb){ try{ cb(rsha) }catch(e){console.warn(e)} }
return rsha;
}
salt = salt || shim.random(9);
@ -302,10 +302,10 @@
}, key, opt.length || (S.pbkdf2.ks * 8))
data = shim.random(data.length) // Erase data in case of passphrase
var r = shim.Buffer.from(work, 'binary').toString(opt.encode || 'base64')
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }
@ -321,10 +321,10 @@
var S = USE('./settings');
SEA.name = SEA.name || (async (cb, opt) => { try {
if(cb){ try{ cb() }catch(e){console.log(e)} }
if(cb){ try{ cb() }catch(e){console.warn(e)} }
return;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }
@ -376,10 +376,10 @@
} dh = dh || {};
var r = { pub: sa.pub, priv: sa.priv, /* pubId, */ epub: dh.epub, epriv: dh.epriv }
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }
@ -409,7 +409,7 @@
&& u !== await SEA.verify(check, pair)){ // don't sign if we already signed it.
var r = await S.parse(check);
if(!opt.raw){ r = 'SEA' + await shim.stringify(r) }
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
}
var pub = pair.pub;
@ -421,10 +421,10 @@
var r = {m: json, s: shim.Buffer.from(sig, 'binary').toString(opt.encode || 'base64')}
if(!opt.raw){ r = 'SEA' + await shim.stringify(r) }
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }
@ -445,7 +445,7 @@
var json = await S.parse(data);
if(false === pair){ // don't verify!
var raw = await S.parse(json.m);
if(cb){ try{ cb(raw) }catch(e){console.log(e)} }
if(cb){ try{ cb(raw) }catch(e){console.warn(e)} }
return raw;
}
opt = opt || {};
@ -465,10 +465,10 @@
}
var r = check? await S.parse(json.m) : u;
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e); // mismatched owner FOR MARTTI
console.warn(e); // mismatched owner FOR MARTTI
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }
@ -508,7 +508,7 @@
}
var r = check? await S.parse(json.m) : u;
O.fall_soul = tmp['#']; O.fall_key = tmp['.']; O.fall_val = data; O.fall_state = tmp['>'];
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
}
SEA.opt.fallback = 2;
@ -560,10 +560,10 @@
}
if(!opt.raw){ r = 'SEA' + await shim.stringify(r) }
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }
@ -603,10 +603,10 @@
}
}
var r = await S.parse(new shim.TextDecoder('utf8').decode(ct));
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }
@ -642,10 +642,10 @@
return ecdhSubtle.exportKey('jwk', derivedKey).then(({ k }) => k);
})
var r = derived;
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }
@ -683,7 +683,7 @@
"cb": A callback function after all things are done.
"opt": If opt.expiry (a timestamp) is set, SEA won't sync data after opt.expiry. If opt.block is set, SEA will look for block before syncing.
*/
console.log('SEA.certify() is an early experimental community supported method that may change API behavior without warning in any future version.')
console.warn('SEA.certify() is an early experimental community supported method that may change API behavior without warning in any future version.')
certificants = (() => {
var data = []
@ -704,7 +704,7 @@
return
})()
if (!certificants) return console.log("No certificant found.")
if (!certificants) return console.warn("No certificant found.")
const expiry = opt.expiry && (typeof opt.expiry === 'number' || typeof opt.expiry === 'string') ? parseFloat(opt.expiry) : null
const readPolicy = (policy || {}).read ? policy.read : null
@ -715,7 +715,7 @@
const readBlock = block.read && (typeof block.read === 'string' || (block.read || {})['#']) ? block.read : null
const writeBlock = typeof block === 'string' ? block : block.write && (typeof block.write === 'string' || block.write['#']) ? block.write : null
if (!readPolicy && !writePolicy) return console.log("No policy found.")
if (!readPolicy && !writePolicy) return console.warn("No policy found.")
// reserved keys: c, e, r, w, rb, wb
const data = JSON.stringify({
@ -731,7 +731,7 @@
var r = certificate
if(!opt.raw){ r = 'SEA'+JSON.stringify(r) }
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
SEA.err = e;
@ -782,7 +782,7 @@
const hash = shim.Buffer.from(sha1, 'binary')
return hash.toString('hex', hash.length - 8) // 16-bit ID as hex
} catch (e) {
console.log(e)
console.warn(e)
throw e
}
});
@ -873,12 +873,12 @@
if(!alias){ err = "No user." }
if((pass||'').length < 8){ err = "Password too short!" }
if(err){
cb({err: Gun.log(err)});
cb({err: Gun.error(err)});
return gun;
}
}
if(cat.ing){
(cb || noop)({err: Gun.log("User is already being created or authenticated!"), wait: true});
(cb || noop)({err: Gun.error("User is already being created or authenticated!"), wait: true});
return gun;
}
cat.ing = true;
@ -887,7 +887,7 @@
act.pubs = pubs;
if(pubs && !opt.already){
// If we can enforce that a user name is already taken, it might be nice to try, but this is not guaranteed.
var ack = {err: Gun.log('User already created!')};
var ack = {err: Gun.error('User already created!')};
cat.ing = false;
(cb || noop)(ack);
gun.leave();
@ -973,7 +973,7 @@
var gun = this, cat = (gun._), root = gun.back(-1);
if(cat.ing){
(cb || noop)({err: Gun.log("User is already being created or authenticated!"), wait: true});
(cb || noop)({err: Gun.warn("User is already being created or authenticated!"), wait: true});
return gun;
}
cat.ing = true;
@ -1051,7 +1051,7 @@
} else { setTimeout(function(){ (root._).on('auth', at) },1) } // if not, hackily add a timeout.
//at.on('auth', at) // Arrgh, this doesn't work without event "merge" code, but "merge" code causes stack overflow and crashes after logging in & trying to write data.
}catch(e){
Gun.log("Your 'auth' callback crashed with:", e);
Gun.warn("Your 'auth' callback crashed with:", e);
}
}
act.h = function(data){
@ -1087,7 +1087,7 @@
root.get('~'+act.pair.pub).get('auth').put(auth, cb || noop);
}
act.err = function(e){
var ack = {err: Gun.log(e || 'User cannot be found!')};
var ack = {err: Gun.error(e || 'User cannot be found!')};
cat.ing = false;
(cb || noop)(ack);
}
@ -1162,7 +1162,7 @@
}
// If authenticated user wants to delete his/her account, let's support it!
User.prototype.delete = async function(alias, pass, cb){
console.log("user.delete() IS DEPRECATED AND WILL BE MOVED TO A MODULE!!!");
console.warn("user.delete() IS DEPRECATED AND WILL BE MOVED TO A MODULE!!!");
var gun = this, root = gun.back(-1), user = gun.back('user');
try {
user.auth(alias, pass, function(ack){
@ -1174,7 +1174,7 @@
(cb || noop)({ok: 0});
});
} catch (e) {
Gun.log('User.delete failed! Error:', e);
Gun.error('User.delete failed! Error:', e);
}
return gun;
}

View File

@ -11,7 +11,7 @@
var gun = this, cat = (gun._), root = gun.back(-1);
if(cat.ing){
(cb || noop)({err: Gun.log("User is already being created or authenticated!"), wait: true});
(cb || noop)({err: Gun.warn("User is already being created or authenticated!"), wait: true});
return gun;
}
cat.ing = true;
@ -85,7 +85,7 @@
} else { setTimeout(function(){ (root._).on('auth', at) },1) } // if not, hackily add a timeout.
//at.on('auth', at) // Arrgh, this doesn't work without event "merge" code, but "merge" code causes stack overflow and crashes after logging in & trying to write data.
}catch(e){
Gun.log("Your 'auth' callback crashed with:", e);
Gun.warn("Your 'auth' callback crashed with:", e);
}
}
act.h = function(data){
@ -121,7 +121,7 @@
root.get('~'+act.pair.pub).get('auth').put(auth, cb || noop);
}
act.err = function(e){
var ack = {err: Gun.log(e || 'User cannot be found!')};
var ack = {err: Gun.error(e || 'User cannot be found!')};
cat.ing = false;
(cb || noop)(ack);
}

View File

@ -2,7 +2,7 @@
var u;
if(u+''== typeof btoa){
if(u+'' == typeof Buffer){
try{ global.Buffer = require("buffer", 1).Buffer }catch(e){ console.log("Please `npm install buffer` or add it to your package.json !") }
try{ global.Buffer = require("buffer", 1).Buffer }catch(e){ console.warn("Please `npm install buffer` or add it to your package.json !") }
}
global.btoa = function(data){ return Buffer.from(data, "binary").toString("base64") };
global.atob = function(data){ return Buffer.from(data, "base64").toString("binary") };

View File

@ -11,7 +11,7 @@
"cb": A callback function after all things are done.
"opt": If opt.expiry (a timestamp) is set, SEA won't sync data after opt.expiry. If opt.block is set, SEA will look for block before syncing.
*/
console.log('SEA.certify() is an early experimental community supported method that may change API behavior without warning in any future version.')
console.warn('SEA.certify() is an early experimental community supported method that may change API behavior without warning in any future version.')
certificants = (() => {
var data = []
@ -32,7 +32,7 @@
return
})()
if (!certificants) return console.log("No certificant found.")
if (!certificants) return console.warn("No certificant found.")
const expiry = opt.expiry && (typeof opt.expiry === 'number' || typeof opt.expiry === 'string') ? parseFloat(opt.expiry) : null
const readPolicy = (policy || {}).read ? policy.read : null
@ -43,7 +43,7 @@
const readBlock = block.read && (typeof block.read === 'string' || (block.read || {})['#']) ? block.read : null
const writeBlock = typeof block === 'string' ? block : block.write && (typeof block.write === 'string' || block.write['#']) ? block.write : null
if (!readPolicy && !writePolicy) return console.log("No policy found.")
if (!readPolicy && !writePolicy) return console.warn("No policy found.")
// reserved keys: c, e, r, w, rb, wb
const data = JSON.stringify({
@ -59,7 +59,7 @@
var r = certificate
if(!opt.raw){ r = 'SEA'+JSON.stringify(r) }
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
SEA.err = e;

View File

@ -17,12 +17,12 @@
if(!alias){ err = "No user." }
if((pass||'').length < 8){ err = "Password too short!" }
if(err){
cb({err: Gun.log(err)});
cb({err: Gun.error(err)});
return gun;
}
}
if(cat.ing){
(cb || noop)({err: Gun.log("User is already being created or authenticated!"), wait: true});
(cb || noop)({err: Gun.error("User is already being created or authenticated!"), wait: true});
return gun;
}
cat.ing = true;
@ -31,7 +31,7 @@
act.pubs = pubs;
if(pubs && !opt.already){
// If we can enforce that a user name is already taken, it might be nice to try, but this is not guaranteed.
var ack = {err: Gun.log('User already created!')};
var ack = {err: Gun.error('User already created!')};
cat.ing = false;
(cb || noop)(ack);
gun.leave();

View File

@ -28,10 +28,10 @@
}
}
var r = await S.parse(new shim.TextDecoder('utf8').decode(ct));
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }

View File

@ -26,10 +26,10 @@
}
if(!opt.raw){ r = 'SEA' + await shim.stringify(r) }
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }

View File

@ -4,10 +4,10 @@
var S = require('./settings');
SEA.name = SEA.name || (async (cb, opt) => { try {
if(cb){ try{ cb() }catch(e){console.log(e)} }
if(cb){ try{ cb() }catch(e){console.warn(e)} }
return;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }
@ -59,10 +59,10 @@
} dh = dh || {};
var r = { pub: sa.pub, priv: sa.priv, /* pubId, */ epub: dh.epub, epriv: dh.epriv }
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }

View File

@ -37,7 +37,7 @@
const hash = shim.Buffer.from(sha1, 'binary')
return hash.toString('hex', hash.length - 8) // 16-bit ID as hex
} catch (e) {
console.log(e)
console.warn(e)
throw e
}
});

View File

@ -24,10 +24,10 @@
return ecdhSubtle.exportKey('jwk', derivedKey).then(({ k }) => k);
})
var r = derived;
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }

View File

@ -10,7 +10,7 @@
}
// If authenticated user wants to delete his/her account, let's support it!
User.prototype.delete = async function(alias, pass, cb){
console.log("user.delete() IS DEPRECATED AND WILL BE MOVED TO A MODULE!!!");
console.warn("user.delete() IS DEPRECATED AND WILL BE MOVED TO A MODULE!!!");
var gun = this, root = gun.back(-1), user = gun.back('user');
try {
user.auth(alias, pass, function(ack){
@ -22,7 +22,7 @@
(cb || noop)({ok: 0});
});
} catch (e) {
Gun.log('User.delete failed! Error:', e);
Gun.error('User.delete failed! Error:', e);
}
return gun;
}

View File

@ -40,7 +40,7 @@
api.ossl = api.subtle = new WebCrypto({directory: 'ossl'}).subtle // ECDH
}
catch(e){
console.log("Please `npm install @peculiar/webcrypto` or add it to your package.json !");
console.warn("Please `npm install @peculiar/webcrypto` or add it to your package.json !");
}}
module.exports = api

View File

@ -18,7 +18,7 @@
&& u !== await SEA.verify(check, pair)){ // don't sign if we already signed it.
var r = await S.parse(check);
if(!opt.raw){ r = 'SEA' + await shim.stringify(r) }
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
}
var pub = pair.pub;
@ -30,10 +30,10 @@
var r = {m: json, s: shim.Buffer.from(sig, 'binary').toString(opt.encode || 'base64')}
if(!opt.raw){ r = 'SEA' + await shim.stringify(r) }
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }

View File

@ -9,7 +9,7 @@
var json = await S.parse(data);
if(false === pair){ // don't verify!
var raw = await S.parse(json.m);
if(cb){ try{ cb(raw) }catch(e){console.log(e)} }
if(cb){ try{ cb(raw) }catch(e){console.warn(e)} }
return raw;
}
opt = opt || {};
@ -29,10 +29,10 @@
}
var r = check? await S.parse(json.m) : u;
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e); // mismatched owner FOR MARTTI
console.warn(e); // mismatched owner FOR MARTTI
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }
@ -72,7 +72,7 @@
}
var r = check? await S.parse(json.m) : u;
O.fall_soul = tmp['#']; O.fall_key = tmp['.']; O.fall_val = data; O.fall_state = tmp['>'];
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
}
SEA.opt.fallback = 2;

View File

@ -15,7 +15,7 @@
data = (typeof data == 'string')? data : await shim.stringify(data);
if('sha' === (opt.name||'').toLowerCase().slice(0,3)){
var rsha = shim.Buffer.from(await sha(data, opt.name), 'binary').toString(opt.encode || 'base64')
if(cb){ try{ cb(rsha) }catch(e){console.log(e)} }
if(cb){ try{ cb(rsha) }catch(e){console.warn(e)} }
return rsha;
}
salt = salt || shim.random(9);
@ -28,10 +28,10 @@
}, key, opt.length || (S.pbkdf2.ks * 8))
data = shim.random(data.length) // Erase data in case of passphrase
var r = shim.Buffer.from(work, 'binary').toString(opt.encode || 'base64')
if(cb){ try{ cb(r) }catch(e){console.log(e)} }
if(cb){ try{ cb(r) }catch(e){console.warn(e)} }
return r;
} catch(e) {
console.log(e);
console.warn(e);
SEA.err = e;
if(SEA.throw){ throw e }
if(cb){ cb() }

View File

@ -99,7 +99,7 @@ function input(msg, cat){ cat = cat || this.as; // TODO: V8 may not be able to o
var root = cat.root, gun = msg.$ || (msg.$ = cat.$), at = (gun||'')._ || empty, tmp = msg.put||'', soul = tmp['#'], key = tmp['.'], change = (u !== tmp['='])? tmp['='] : tmp[':'], state = tmp['>'] || -Infinity, sat; // eve = event, at = data at, cat = chain at, sat = sub at (children chains).
if(u !== msg.put && (u === tmp['#'] || u === tmp['.'] || (u === tmp[':'] && u === tmp['=']) || u === tmp['>'])){ // convert from old format
if(!valid(tmp)){
if(!(soul = ((tmp||'')._||'')['#'])){ console.log("chain not yet supported for", tmp, '...', msg, cat); return; }
if(!(soul = ((tmp||'')._||'')['#'])){ console.warn("chain not yet supported for", tmp, '...', msg, cat); return; }
gun = cat.root.$.get(soul);
return setTimeout.each(Object.keys(tmp).sort(), function(k){ // TODO: .keys( is slow // BUG? ?Some re-in logic may depend on this being sync?
if('_' == k || u === (state = state_is(tmp, k))){ return }

View File

@ -4,7 +4,7 @@ Gun.chain.get = function(key, cb, as){
var gun, tmp;
if(typeof key === 'string'){
if(key.length == 0) {
(gun = this.chain())._.err = {err: Gun.log('0 length key!', key)};
(gun = this.chain())._.err = {err: Gun.warn('0 length key!', key)};
if(cb){ cb.call(gun, gun._.err) }
return gun;
}
@ -95,7 +95,7 @@ Gun.chain.get = function(key, cb, as){
gun = tmp(this, key);
}
if(!gun){
(gun = this.chain())._.err = {err: Gun.log('Invalid get request!', key)}; // CLEAN UP
(gun = this.chain())._.err = {err: Gun.warn('Invalid get request!', key)}; // CLEAN UP
if(cb){ cb.call(gun, gun._.err) }
return gun;
}

View File

@ -4,7 +4,7 @@ if(typeof Gun === 'undefined'){ return }
var noop = function(){}, store, u;
try{store = (Gun.window||noop).localStorage}catch(e){}
if(!store){
Gun.log("Warning: No localStorage exists to persist data to!");
Gun.warn("No localStorage exists to persist data to!");
store = {setItem: function(k,v){this[k]=v}, removeItem: function(k){delete this[k]}, getItem: function(k){return this[k]}};
}
@ -51,7 +51,7 @@ Gun.on('create', function lg(root){
try{!err && store.setItem(opt.prefix, tmp);
}catch(e){ err = stop = e || "localStorage failure" }
if(err){
Gun.log(err + " Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install");
Gun.error(err + " Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install");
root.on('localStorage:error', {err: err, get: opt.prefix, put: disk});
}
size = tmp.length;

View File

@ -22,7 +22,7 @@ Gun.chain.map = function(cb, opt, t){
gun.on('in', map, chain._);
return chain;
}
Gun.log.once("mapfn", "Map functions are experimental, their behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it.");
Gun.warn.once("mapfn", "Map functions are experimental, their behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it.");
chain = gun.chain();
gun.map().on(function(data, key, msg, eve){
var next = (cb||noop).call(this, data, key, msg, eve);

View File

@ -4,12 +4,14 @@ require('./shim');
var noop = function(){}
var parse = JSON.parseAsync || function(t,cb,r){ var u, d = +new Date; try{ cb(u, JSON.parse(t,r), json.sucks(+new Date - d)) }catch(e){ cb(e) } }
var json = JSON.stringifyAsync || function(v,cb,r,s){ var u, d = +new Date; try{ cb(u, JSON.stringify(v,r,s), json.sucks(+new Date - d)) }catch(e){ cb(e) } }
json.sucks = function(d){ if(d > 99){ console.log("Warning: JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."); json.sucks = noop } }
json.sucks = function(d){ if(d > 99){ console.warn("JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."); json.sucks = noop } }
function Mesh(root){
var mesh = function(){};
var opt = root.opt || {};
opt.log = opt.log || console.log;
opt.warn = opt.warn || console.warn;
opt.error = opt.error || console.error;
opt.gap = opt.gap || opt.wait || 0;
opt.max = opt.max || (opt.memory? (opt.memory * 999 * 999) : 300000000) * 0.3;
opt.pack = opt.pack || (opt.max * 0.01 * 0.01);
@ -237,7 +239,7 @@ function Mesh(root){
if(!tmp){ return }
if(t? 3 > tmp.length : !tmp.length){ return } // TODO: ^
if(!t){try{tmp = (1 === tmp.length? tmp[0] : JSON.stringify(tmp));
}catch(e){return opt.log('DAM JSON stringify error', e)}}
}catch(e){return opt.error('DAM JSON stringify error', e)}}
if(!tmp){ return }
send(tmp, peer);
}
@ -285,7 +287,7 @@ function Mesh(root){
var tmp = +(new Date); tmp = (tmp - (peer.met||tmp));
mesh.bye.time = ((mesh.bye.time || tmp) + tmp) / 2;
}
mesh.hear['!'] = function(msg, peer){ opt.log('Error:', msg.err) }
mesh.hear['!'] = function(msg, peer){ opt.error('Error:', msg.err) }
mesh.hear['?'] = function(msg, peer){
if(msg.pid){
if(!peer.pid){ peer.pid = msg.pid }
@ -326,7 +328,7 @@ function Mesh(root){
if(tmp = console.STAT){ tmp.peers = mesh.near }
if(opt.super){ return } // temporary (?) until we have better fix/solution?
var souls = Object.keys(root.next||''); // TODO: .keys( is slow
if(souls.length > 9999 && !console.SUBS){ console.log(console.SUBS = "Warning: You have more than 10K live GETs, which might use more bandwidth than your screen can show - consider `.off()`.") }
if(souls.length > 9999 && !console.SUBS){ console.warn(console.SUBS = "You have more than 10K live GETs, which might use more bandwidth than your screen can show - consider `.off()`.") }
setTimeout.each(souls, function(soul){ var node = root.next[soul];
if(opt.super || (node.ask||'')['']){ mesh.say({get: {'#': soul}}, peer); return }
setTimeout.each(Object.keys(node.ask||''), function(key){ if(!key){ return }

View File

@ -83,7 +83,7 @@ Gun.chain.once = function(cb, opt){ opt = opt || {}; // avoid rewriting
return gun;
}
function none(gun,opt,chain){
Gun.log.once("valonce", "Chainable val is experimental, its behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it.");
Gun.warn.once("valonce", "Chainable val is experimental, its behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it.");
(chain = gun.chain())._.nix = gun.once(function(data, key){ chain._.on('in', this._) });
chain._.lex = gun._.lex; // TODO: Better approach in future? This is quick for now.
return chain;

View File

@ -193,7 +193,7 @@ Gun.ask = require('./ask');
var ERR = "Error: Invalid graph!";
var cut = function(s){ return " '"+(''+s).slice(0,9)+"...' " }
var L = JSON.stringify, MD = 2147483647, State = Gun.state;
var C = 0, CT, CF = function(){if(C>999 && (C/-(CT - (CT = +new Date))>1)){Gun.window && console.log("Warning: You're syncing 1K+ records a second, faster than DOM can update - consider limiting query.");CF=function(){C=0}}};
var C = 0, CT, CF = function(){if(C>999 && (C/-(CT - (CT = +new Date))>1)){Gun.window && console.warn("You're syncing 1K+ records a second, faster than DOM can update - consider limiting query.");CF=function(){C=0}}};
}());
@ -290,7 +290,11 @@ Gun.ask = require('./ask');
var obj_each = function(o,f){ Object.keys(o).forEach(f,o) }, text_rand = String.random, turn = setTimeout.turn, valid = Gun.valid, state_is = Gun.state.is, state_ify = Gun.state.ify, u, empty = {}, C;
Gun.log = function(){ return (!Gun.log.off && C.log.apply(C, arguments)), [].slice.call(arguments).join(' ') };
Gun.warn = function(){ return (!Gun.log.off && !Gun.warn.off && C.warn.apply(C, arguments)), [].slice.call(arguments).join(' ') };
Gun.error = function(){ return (!Gun.log.off && !Gun.error.off && C.error.apply(C, arguments)), [].slice.call(arguments).join(' ') };
Gun.log.once = function(w,s,o){ return (o = Gun.log.once)[w] = o[w] || 0, o[w]++ || Gun.log(s) };
Gun.warn.once = function(w,s,o){ return (o = Gun.warn.once)[w] = o[w] || 0, o[w]++ || Gun.warn(s) };
Gun.error.once = function(w,s,o){ return (o = Gun.error.once)[w] = o[w] || 0, o[w]++ || Gun.error(s) };
if(typeof window !== "undefined"){ (window.GUN = window.Gun = Gun).window = window }
try{ if(typeof MODULE !== "undefined"){ MODULE.exports = Gun } }catch(e){}

View File

@ -14,7 +14,7 @@ Gun.chain.set = function(item, cb, opt){
}
gun.put(function(go){
item.get(function(soul, o, msg){ // TODO: BUG! We no longer have this option? & go error not handled?
if(!soul){ return cb.call(gun, {err: Gun.log('Only a node can be linked! Not "' + msg.put + '"!')}) }
if(!soul){ return cb.call(gun, {err: Gun.warn('Only a node can be linked! Not "' + msg.put + '"!')}) }
(tmp = {})[soul] = {'#': soul}; go(tmp);
},true);
})

View File

@ -4001,7 +4001,7 @@ describe('Gun', function(){
}
return false;
} else {
console.warn('filter should be an Array');
console.warn('Filter should be an Array');
return false;
}
}
@ -7490,7 +7490,7 @@ describe('Gun', function(){
return cb.call(gun, null, data);
}, opt);
} else {
//console.Log("Warning! You have no persistence layer to save to!");
//console.warn("You have no persistence layer to save to!");
cb.call(gun, null); // This is in memory success, hardly "success" at all.
}
});

View File

@ -69,7 +69,7 @@ describe("Stress test GUN with SEA users causing PANIC!", function(){
// As a result, we have to manually pass it scope.
test.async();
// Clean up from previous test.
try{ require('fs').unlinkSync(env.i+'data') }catch(e){ console.log("!!! WARNING !!!! MUST MANUALLY REMOVE OLD DATA!!!!, e") }
try{ require('fs').unlinkSync(env.i+'data') }catch(e){ console.warn("MUST MANUALLY REMOVE OLD DATA!!!!, e") }
var purl = 'https://'+env.config.IP+':'+env.config.port;
require('gun/test/https/test')(env.config.port + env.i, env.i+'data', function(){
// This server peer is now done with the test!

View File

@ -71,7 +71,7 @@ describe("Stress test GUN with SEA users causing PANIC!", function(){
test.async();
//setInterval(function(){ var u, t; u = process.memoryUsage().heapUsed; t = require('os').totalmem(); console.log((u/t).toFixed(2)) }, 1000)
// Clean up from previous test.
try{ require('fs').unlinkSync(env.i+'data') }catch(e){ console.log("!!! WARNING !!!! MUST MANUALLY REMOVE OLD DATA!!!!, e") }
try{ require('fs').unlinkSync(env.i+'data') }catch(e){ console.warn("MUST MANUALLY REMOVE OLD DATA!!!!, e") }
var purl = 'https://'+env.config.IP+':'+env.config.port;
require('gun/test/https/test')(env.config.port + env.i, env.i+'data', function(){
// This server peer is now done with the test!

View File

@ -50,7 +50,7 @@ describe('SEA', function(){
indexedDB.deleteDatabase('radatatest').onsuccess = function(e){ done() }
});
/*it('generates aeskey from jwk', function(done) { // DEPRECATED!!!
console.log("WARNING: THIS DOES NOT WORK IN BROWSER!!!! NEEDS FIX");
console.warn("THIS DOES NOT WORK IN BROWSER!!!! NEEDS FIX");
SEA.opt.aeskey('x','x').then(k => {
//console.log("DATA", k.data);
expect(k.data.toString('base64')).to.be('Xd6JaIf2dUybFb/jpEGuSAbfL96UABMR4IvxEGIuC74=')

View File

@ -11,7 +11,7 @@ Trace.log = function(evname, msg) {
// Trace.on('trace.end', {code: Trace.traces.join('\n')});
// }, 1000);
if (!msg) {
//console.log('WARN, empty message: ',msg);
//console.warn('Empty message: ',msg);
// msg=evname;
// evname = 'GUN';
}