Skip to content

Class: BindingMagicString

Defined in: binding.d.cts:1423

Constructors

Constructor

new BindingMagicString(source, options?): BindingMagicString

Defined in: binding.d.cts:1424

Parameters

source

string

options?

BindingMagicStringOptions | null

Returns

BindingMagicString

Accessors

filename

Get Signature

get filename(): string | null

Defined in: binding.d.cts:1425
Returns

string | null

Methods

append()

append(content): this

Defined in: binding.d.cts:1429

Parameters

content

string

Returns

this


appendLeft()

appendLeft(index, content): this

Defined in: binding.d.cts:1432

Parameters

index

number

content

string

Returns

this


appendRight()

appendRight(index, content): this

Defined in: binding.d.cts:1433

Parameters

index

number

content

string

Returns

this


clone()

clone(): BindingMagicString

Defined in: binding.d.cts:1463

Returns a clone of the MagicString instance.

Returns

BindingMagicString


hasChanged()

hasChanged(): boolean

Defined in: binding.d.cts:1436

Returns

boolean


indent()

indent(indentor?): this

Defined in: binding.d.cts:1448

Parameters

indentor?

string | null

Returns

this


insert()

insert(index, content): void

Defined in: binding.d.cts:1461

Deprecated method that throws an error directing users to use prependRight or appendLeft. This matches the original magic-string API which deprecated this method.

Parameters

index

number

content

string

Returns

void


isEmpty()

isEmpty(): boolean

Defined in: binding.d.cts:1438

Returns

boolean


lastChar()

lastChar(): string

Defined in: binding.d.cts:1465

Returns the last character of the generated string, or an empty string if empty.

Returns

string


lastLine()

lastLine(): string

Defined in: binding.d.cts:1467

Returns the content after the last newline in the generated string.

Returns

string


length()

length(): number

Defined in: binding.d.cts:1437

Returns

number


move()

move(start, end, index): this

Defined in: binding.d.cts:1447

Alias for relocate to match the original magic-string API. Moves the characters from start to end to index. Returns this for method chaining.

Parameters

start

number

end

number

index

number

Returns

this


overwrite()

overwrite(start, end, content): this

Defined in: binding.d.cts:1434

Parameters

start

number

end

number

content

string

Returns

this


prepend()

prepend(content): this

Defined in: binding.d.cts:1428

Parameters

content

string

Returns

this


prependLeft()

prependLeft(index, content): this

Defined in: binding.d.cts:1430

Parameters

index

number

content

string

Returns

this


prependRight()

prependRight(index, content): this

Defined in: binding.d.cts:1431

Parameters

index

number

content

string

Returns

this


relocate()

relocate(start, end, to): this

Defined in: binding.d.cts:1441

Parameters

start

number

end

number

to

number

Returns

this


remove()

remove(start, end): this

Defined in: binding.d.cts:1439

Parameters

start

number

end

number

Returns

this


replace()

replace(from, to): this

Defined in: binding.d.cts:1426

Parameters

from

string

to

string

Returns

this


replaceAll()

replaceAll(from, to): this

Defined in: binding.d.cts:1427

Parameters

from

string

to

string

Returns

this


reset()

reset(start, end): this

Defined in: binding.d.cts:1475

Resets the portion of the string from start to end to its original content. This undoes any modifications made to that range. Supports negative indices (counting from the end).

Parameters

start

number

end

number

Returns

this


slice()

slice(start?, end?): string

Defined in: binding.d.cts:1480

Returns the content between the specified original character positions. Supports negative indices (counting from the end).

Parameters

start?

number | null

end?

number | null

Returns

string


snip()

snip(start, end): BindingMagicString

Defined in: binding.d.cts:1469

Returns a clone with content outside the specified range removed.

Parameters

start

number

end

number

Returns

BindingMagicString


toString()

toString(): string

Defined in: binding.d.cts:1435

Returns

string


trim()

trim(charType?): this

Defined in: binding.d.cts:1450

Trims whitespace or specified characters from the start and end.

Parameters

charType?

string | null

Returns

this


trimEnd()

trimEnd(charType?): this

Defined in: binding.d.cts:1454

Trims whitespace or specified characters from the end.

Parameters

charType?

string | null

Returns

this


trimLines()

trimLines(): this

Defined in: binding.d.cts:1456

Trims newlines from the start and end.

Returns

this


trimStart()

trimStart(charType?): this

Defined in: binding.d.cts:1452

Trims whitespace or specified characters from the start.

Parameters

charType?

string | null

Returns

this


update()

update(start, end, content): this

Defined in: binding.d.cts:1440

Parameters

start

number

end

number

content

string

Returns

this