aboutsummaryrefslogtreecommitdiff
path: root/node_modules/last-line-stream/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/last-line-stream/index.js')
-rw-r--r--node_modules/last-line-stream/index.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/node_modules/last-line-stream/index.js b/node_modules/last-line-stream/index.js
new file mode 100644
index 000000000..2ecc37adf
--- /dev/null
+++ b/node_modules/last-line-stream/index.js
@@ -0,0 +1,24 @@
+'use strict';
+var through2 = require('through2');
+var StringDecoder = require('string_decoder').StringDecoder;
+var createTracker = require('./tracker');
+
+module.exports = function (pipeDestination) {
+ var decoder = new StringDecoder();
+ var tracker = createTracker();
+
+ var stream = through2(function (chunk, enc, cb) {
+ tracker.update(decoder.write(chunk));
+ cb(null, chunk);
+ });
+
+ Object.defineProperty(stream, 'lastLine', {
+ get: tracker.lastLine
+ });
+
+ if (pipeDestination) {
+ stream.pipe(pipeDestination);
+ }
+
+ return stream;
+};