You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
409 B
JavaScript
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
|
|
};
|
|
};
|