stream-log-stats
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -6,2 +6,2 @@ #!/usr/bin/env node | ||
process.stdin.pipe(statsView()).pipe(process.stdout); | ||
process.stdin.pipe(statsView()); |
@@ -65,2 +65,2 @@ "use strict"; | ||
this.transferred = byteSize(this.bytes, 2); | ||
}; | ||
}; |
@@ -0,3 +1,6 @@ | ||
"use strict"; | ||
var Transform = require("stream").Transform, | ||
Clf = require("common-log-format"), | ||
f = require("function-tools"), | ||
util = require("util"), | ||
@@ -7,14 +10,21 @@ view = require("./view"), | ||
module.exports = StatsView; | ||
var throttledRender = f.throttle(view.render, { restPeriod: 500 }); | ||
module.exports = function(options){ | ||
var clf = new Clf(options); | ||
var statsView = new StatsView(options); | ||
clf.pipe(statsView); | ||
return clf; | ||
}; | ||
function StatsView(options){ | ||
if (!(this instanceof StatsView)) return new StatsView(options); | ||
Transform.call(this, options); | ||
this._buffer = ""; | ||
} | ||
util.inherits(StatsView, Transform); | ||
var buf = ""; | ||
StatsView.prototype._transform = function(chunk, enc, done){ | ||
var input = chunk.toString(); | ||
input = buf + input; | ||
input = this._buffer + input; | ||
var matches = input.match(/\{.*?\}/g); | ||
@@ -29,8 +39,8 @@ if (matches){ | ||
}); | ||
buf = input.replace(matches.join(""), ""); | ||
view.render(stats); | ||
this._buffer = input.replace(matches.join(""), ""); | ||
throttledRender(stats); | ||
} else { | ||
buf = input; | ||
this._buffer = input; | ||
} | ||
done(); | ||
}; |
{ | ||
"name": "stream-log-stats", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "", | ||
@@ -25,5 +25,7 @@ "repository": "https://github.com/75lb/stream-log-stats.git", | ||
"byte-size": "^0.1.0", | ||
"common-log-format": "^0.1.3", | ||
"console-dope": "^0.3.4", | ||
"function-tools": "^0.1.0", | ||
"object-tools": "^1.0.3" | ||
} | ||
} |
6726
138
6
+ Addedcommon-log-format@^0.1.3
+ Addedfunction-tools@^0.1.0
+ Addedcommon-log-format@0.1.4(transitive)
+ Addedfunction-tools@0.1.2(transitive)