★ replaceText()

Returns the primitive value with replaced text.

Wrap.prototype.replaceText()

Returns the primitive value with replaced text.

wrap.class.ts
public replaceText<ReplaceText extends string = ''>(
  text: ReplaceText
): `${Opening}${ReplaceText}${Closing}` {
  return `${this.#opening}${text}${this.#closing}`;
}

Generic type variables

ReplaceTextextendsstring=''

A generic type variable constrained by the string, by default of the value captured from the provided text indicates the ReplaceText type on the template of the return type.

Parameters

text: ReplaceText

The text of a generic type variable ReplaceText to replace the text in the primitive value.

Return type

${Opening}${ReplaceText}${Closing}

The return type is the template literal of generic type variables in order Opening, ReplaceText and Closing.

Returns

The return value is the primitive value with replaced text of a generic type variables in order Opening, ReplaceText and Closing on the template.

Example usage

// Example usage.
import { Wrap } from '@angular-package/wrapper';

// Returns [span] of type "[span]".
new Wrap(`[`, `]`, 'quote').replaceText('span');

// Returns [bold] of "[bold]".
new Wrap(`[`, `]`, '').replaceText('bold');

// Returns [u] of "[u]".
new Wrap(`[`, `]`).replaceText('u');

// Returns size] of "size]".
new Wrap(``, `]`).replaceText('size');

// Returns [size of "[size".
new Wrap(`[`, ``).replaceText('size');

Last updated