wallet-core/node_modules/last-line-stream/tracker.js
2017-05-28 00:40:43 +02:00

27 lines
409 B
JavaScript

'use strict';
module.exports = function () {
var lastLine = [''];
function update(str) {
var idx = str.lastIndexOf('\n');
if (idx === -1) {
lastLine.push(str);
} else {
lastLine = [str.substring(idx + 1)];
}
}
function getLastLine() {
if (lastLine.length > 1) {
lastLine = [lastLine.join('')];
}
return lastLine[0];
}
return {
update: update,
lastLine: getLastLine
};
};