MCPcopy Create free account
hub / github.com/Rich-Harris/magic-string / lastLine

Method lastLine

benchmark/data.js:609–634  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

607 return '';
608 }
609 lastLine() {
610 let lineIndex = this.outro.lastIndexOf(n);
611 if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
612 let lineStr = this.outro;
613 let chunk = this.lastChunk;
614 do {
615 if (chunk.outro.length > 0) {
616 lineIndex = chunk.outro.lastIndexOf(n);
617 if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
618 lineStr = chunk.outro + lineStr;
619 }
620 if (chunk.content.length > 0) {
621 lineIndex = chunk.content.lastIndexOf(n);
622 if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
623 lineStr = chunk.content + lineStr;
624 }
625 if (chunk.intro.length > 0) {
626 lineIndex = chunk.intro.lastIndexOf(n);
627 if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
628 lineStr = chunk.intro + lineStr;
629 }
630 } while ((chunk = chunk.previous));
631 lineIndex = this.intro.lastIndexOf(n);
632 if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
633 return this.intro + lineStr;
634 }
635 slice(start = 0, end = this.original.length) {
636 if (this.original.length !== 0) {
637 while (start < 0) start += this.original.length;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected