This commit is contained in:
John Behan 2017-12-05 14:19:36 +00:00
parent 76aa1addb8
commit 22d0e023ee
2 changed files with 14 additions and 15 deletions

View File

@ -1,12 +1,13 @@
const normal = '▒'
const crazy = '▇'
export default (valuefn=(ary)=>ary.length, threshold=100, yellowbox=false)=>events=>events.do(
(infoAry)=>{
const len = valuefn(infoAry)
if(yellowbox && len >= threshold){
console.warn(`bars: event rate over threshold (${threshold}): ${len}`)
const normal = '▒';
const crazy = '▇';
export default (valuefn = ary => ary.length, threshold = 100, yellowbox = false) => events => events.do(
infoAry => {
const len = valuefn(infoAry);
if (yellowbox && len >= threshold) {
console.warn(`bars: event rate over threshold (${threshold}): ${len}`);
}
console.log("tick", (len >= threshold ? crazy : normal).repeat(Math.floor(Math.log(Math.max(len,1)))) + `(${len})`)
console.log('tick', (len >= threshold ?
crazy
: normal).repeat(Math.floor(Math.log(Math.max(len, 1)))) + `(${len})`);
}
)
);

View File

@ -4,13 +4,11 @@ import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/bufferTime';
import { spy as log } from '../log'
class Stream {
constructor (emitter) {
this.events = Observable.fromEvent(emitter, 'mqspy')
this.spy = (info) => emitter.emit('mqspy', info)
this.events = Observable.fromEvent(emitter, 'mqspy');
this.spy = info => emitter.emit('mqspy', info);
}
}
export default Stream
export default Stream;