simplify filter expression for GUN message logging

This commit is contained in:
Jesse D. McDonald 2020-03-30 00:05:48 -05:00
parent d329f005da
commit d37cb4a67f
1 changed files with 6 additions and 8 deletions

View File

@ -10,19 +10,17 @@ $(function (){
peers: ['https://jessemcdonald.info/gun'], peers: ['https://jessemcdonald.info/gun'],
}); });
gun._.on('in', function(msg) { gun.on('in', function(msg) {
if (window.logGunIn && const filter = window.logGunIn;
(typeof window.logGunIn !== 'function' || if (filter && ((typeof filter !== 'function') || filter(msg)))
window.logGunIn(msg)))
{ {
console.log('in msg: ', msg); console.log('in msg: ', msg);
} }
}); });
gun._.on('out', function(msg) { gun.on('out', function(msg) {
if (window.logGunOut && const filter = window.logGunOut;
(typeof window.logGunOut !== 'function' || if (filter && ((typeof filter !== 'function') || filter(msg)))
window.logGunOut(msg)))
{ {
console.log('out msg: ', msg); console.log('out msg: ', msg);
} }