★ replaceText()
Wrap.prototype.replaceText()
Wrap.prototype.replaceText()Returns the primitive value with replaced text.
public replaceText<ReplaceText extends string = ''>(
text: ReplaceText
): `${Opening}${ReplaceText}${Closing}` {
return `${this.#opening}${text}${this.#closing}`;
}Generic type variables
ReplaceTextextendsstring=''
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
text: ReplaceTextThe text of a generic type variable ReplaceText to replace the text in the primitive value.
Return type
${Opening}${ReplaceText}${Closing}
${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
Was this helpful?