wallet-core/node_modules/last-line-stream/tracker.js

27 lines
409 B
JavaScript
Raw Normal View History

2017-05-28 00:38:50 +02:00
'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
};
};