SimpleChat:DU: Make NewLines shift more robust and flexible
This commit is contained in:
parent
b7a5424c13
commit
7251714bcb
1 changed files with 17 additions and 2 deletions
|
@ -202,7 +202,9 @@ export function trim_garbage_at_end(sIn) {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NewLines array helper
|
* NewLines array helper.
|
||||||
|
* Allow for maintaining a list of lines.
|
||||||
|
* Allow for a line to be builtup/appended part by part.
|
||||||
*/
|
*/
|
||||||
export class NewLines {
|
export class NewLines {
|
||||||
|
|
||||||
|
@ -244,7 +246,20 @@ export class NewLines {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shift() {
|
/**
|
||||||
|
* Shift the oldest/0th line in the array.
|
||||||
|
* Optionally control whether only full lines will be returned
|
||||||
|
* or will a partial line (last line) be returned.
|
||||||
|
* @param {boolean} bFullOnly
|
||||||
|
*/
|
||||||
|
shift(bFullOnly=true) {
|
||||||
|
let line = this.lines[0];
|
||||||
|
if (line == undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if ((line[line.length-1] != "\n") && bFullOnly){
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return this.lines.shift();
|
return this.lines.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue