node-lib

@wtasnorg/node-lib


@wtasnorg/node-lib / ReplacerString

Class: ReplacerString

Defined in: src/strings.ts:1526

Replacer replaces a list of strings with replacements. Instances are immutable after construction and can be safely reused across multiple calls and asynchronous tasks.

Example

const r = newReplacer("<", "&lt;", ">", "&gt;");
console.log(r.replace("<html>")); // "&lt;html&gt;"

Constructors

Constructor

new ReplacerString(…oldnew): Replacer

Defined in: src/strings.ts:1529

Parameters

oldnew

string[]

Returns

Replacer

Methods

replace()

replace(s): string

Defined in: src/strings.ts:1545

Replace returns a copy of s with all replacements performed.

Parameters

s

string

Input string.

Returns

string

String with replacements applied.


writeString()

writeString(w, s): number

Defined in: src/strings.ts:1574

WriteString writes to w the output of r.Replace(s).

Parameters

w

WriterString

Writer to write to.

s

string

Input string.

Returns

number

Number of bytes written.