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

Class f

benchmark/data-min.js:228–673  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226`,
227 c = { insertLeft: !1, insertRight: !1, storeName: !1 };
228class f {
229 constructor(t, e = {}) {
230 const n = new g(0, t.length, t);
231 (Object.defineProperties(this, {
232 original: { writable: !0, value: t },
233 outro: { writable: !0, value: '' },
234 intro: { writable: !0, value: '' },
235 firstChunk: { writable: !0, value: n },
236 lastChunk: { writable: !0, value: n },
237 lastSearchedChunk: { writable: !0, value: n },
238 byStart: { writable: !0, value: {} },
239 byEnd: { writable: !0, value: {} },
240 filename: { writable: !0, value: e.filename },
241 indentExclusionRanges: { writable: !0, value: e.indentExclusionRanges },
242 sourcemapLocations: { writable: !0, value: new p() },
243 storedNames: { writable: !0, value: {} },
244 indentStr: { writable: !0, value: L(t) },
245 }),
246 (this.byStart[0] = n),
247 (this.byEnd[t.length] = n));
248 }
249 addSourcemapLocation(t) {
250 this.sourcemapLocations.add(t);
251 }
252 append(t) {
253 if (typeof t != 'string') throw new TypeError('outro content must be a string');
254 return ((this.outro += t), this);
255 }
256 appendLeft(t, e) {
257 if (typeof e != 'string') throw new TypeError('inserted content must be a string');
258 this._split(t);
259 const n = this.byEnd[t];
260 return (n ? n.appendLeft(e) : (this.intro += e), this);
261 }
262 appendRight(t, e) {
263 if (typeof e != 'string') throw new TypeError('inserted content must be a string');
264 this._split(t);
265 const n = this.byStart[t];
266 return (n ? n.appendRight(e) : (this.outro += e), this);
267 }
268 clone() {
269 const t = new f(this.original, { filename: this.filename });
270 let e = this.firstChunk,
271 n = (t.firstChunk = t.lastSearchedChunk = e.clone());
272 for (; e; ) {
273 ((t.byStart[n.start] = n), (t.byEnd[n.end] = n));
274 const i = e.next,
275 r = i && i.clone();
276 (r && ((n.next = r), (r.previous = n), (n = r)), (e = i));
277 }
278 return (
279 (t.lastChunk = n),
280 this.indentExclusionRanges && (t.indentExclusionRanges = this.indentExclusionRanges.slice()),
281 (t.sourcemapLocations = new p(this.sourcemapLocations)),
282 (t.intro = this.intro),
283 (t.outro = this.outro),
284 t
285 );

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected