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

Method indent

benchmark/data-min.js:773–794  ·  view source on GitHub ↗
(t)

Source from the content-addressed store, hash-verified

771 );
772 }
773 indent(t) {
774 if ((arguments.length || (t = this.getIndentString()), t === '')) return this;
775 let e =
776 !this.intro ||
777 this.intro.slice(-1) ===
778 `
779`;
780 return (
781 this.sources.forEach((n, i) => {
782 const r = n.separator !== void 0 ? n.separator : this.separator,
783 s = e || (i > 0 && /\r?\n$/.test(r));
784 (n.content.indent(t, { exclude: n.indentExclusionRanges, indentStart: s }),
785 (e =
786 n.content.lastChar() ===
787 `
788`));
789 }),
790 this.intro &&
791 (this.intro = t + this.intro.replace(/^[^\n]/gm, (n, i) => (i > 0 ? t + n : n))),
792 this
793 );
794 }
795 prepend(t) {
796 return ((this.intro = t + this.intro), this);
797 }

Callers

nothing calls this directly

Calls 5

getIndentStringMethod · 0.95
sliceMethod · 0.45
indentMethod · 0.45
lastCharMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected