|
436 | 436 | var ERR = "Error: Invalid graph!"; |
437 | 437 | var cut = function(s){ return " '"+(''+s).slice(0,9)+"...' " } |
438 | 438 | var L = JSON.stringify, MD = 2147483647, State = Gun.state; |
439 | | - 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}}}; |
| 439 | + 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}}}; |
440 | 440 |
|
441 | 441 | }()); |
442 | 442 |
|
|
1380 | 1380 | var noop = function(){} |
1381 | 1381 | 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) } } |
1382 | 1382 | 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) } } |
1383 | | - json.sucks = function(d){ if(d > 99){ console.log("Warning: JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."); json.sucks = noop } } |
| 1383 | + json.sucks = function(d){ if(d > 99){ console.warn("JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."); json.sucks = noop } } |
1384 | 1384 |
|
1385 | 1385 | function Mesh(root){ |
1386 | 1386 | var mesh = function(){}; |
1387 | 1387 | var opt = root.opt || {}; |
1388 | 1388 | opt.log = opt.log || console.log; |
| 1389 | + opt.warn = opt.warn || console.warn; |
| 1390 | + opt.error = opt.error || console.error; |
1389 | 1391 | opt.gap = opt.gap || opt.wait || 0; |
1390 | 1392 | opt.max = opt.max || (opt.memory? (opt.memory * 999 * 999) : 300000000) * 0.3; |
1391 | 1393 | opt.pack = opt.pack || (opt.max * 0.01 * 0.01); |
|
1619 | 1621 | if(!tmp){ return } |
1620 | 1622 | if(t? 3 > tmp.length : !tmp.length){ return } // TODO: ^ |
1621 | 1623 | if(!t){try{tmp = (1 === tmp.length? tmp[0] : JSON.stringify(tmp)); |
1622 | | - }catch(e){return opt.log('DAM JSON stringify error', e)}} |
| 1624 | + }catch(e){return opt.error('DAM JSON stringify error', e)}} |
1623 | 1625 | if(!tmp){ return } |
1624 | 1626 | send(tmp, peer); |
1625 | 1627 | } |
|
1667 | 1669 | var tmp = +(new Date); tmp = (tmp - (peer.met||tmp)); |
1668 | 1670 | mesh.bye.time = ((mesh.bye.time || tmp) + tmp) / 2; |
1669 | 1671 | } |
1670 | | - mesh.hear['!'] = function(msg, peer){ opt.log('Error:', msg.err) } |
| 1672 | + mesh.hear['!'] = function(msg, peer){ opt.error('Error:', msg.err) } |
1671 | 1673 | mesh.hear['?'] = function(msg, peer){ |
1672 | 1674 | if(msg.pid){ |
1673 | 1675 | if(!peer.pid){ peer.pid = msg.pid } |
|
1794 | 1796 | var noop = function(){}, store, u; |
1795 | 1797 | try{store = (Gun.window||noop).localStorage}catch(e){} |
1796 | 1798 | if(!store){ |
1797 | | - Gun.log("Warning: No localStorage exists to persist data to!"); |
| 1799 | + Gun.warn("No localStorage exists to persist data to!"); |
1798 | 1800 | store = {setItem: function(k,v){this[k]=v}, removeItem: function(k){delete this[k]}, getItem: function(k){return this[k]}}; |
1799 | 1801 | } |
1800 | 1802 |
|
|
1862 | 1864 | ;(function(){ |
1863 | 1865 | var u; |
1864 | 1866 | if(''+u == typeof Gun){ return } |
1865 | | - var DEP = function(n){ console.warn("Warning! Deprecated internal utility will break in next version:", n) } |
| 1867 | + var DEP = function(n){ console.warn("Deprecated internal utility will break in next version:", n) } |
1866 | 1868 | // Generic javascript utilities. |
1867 | 1869 | var Type = Gun; |
1868 | 1870 | //Type.fns = Type.fn = {is: function(fn){ return (!!fn && fn instanceof Function) }} |
|
0 commit comments