★ wrapText()

Wrapper.prototype.wrapText()

The method returns the primitive value of the Wrapper object with text wrapped by given opening and closing chars.

wrapper.class.ts
public wrapText<
  TextOpening extends string = '',
  TextClosing extends string = ''
>(
  opening: TextOpening,
  closing: TextClosing
): Wrapped<Opening, Wrapped<TextOpening, Text, TextClosing>, Closing> {
  return `${this.opening}${this.textWrap(opening, closing)}${this.closing}`;
}

Generic type variables

TextOpeningextendsstring=''

A generic type variable constrained by the string indicates the captured type of the supplied opening parameter and the Opening type in the generic type Wrapped via return type, by default an empty string.

TextClosingextendsstring=''

A generic type variable constrained by the string indicates the captured type of the supplied closing parameter and the Closing type in the generic type Wrapped via return type, by default an empty string.

Parameters

opening:TextOpening

The opening chars of a generic type variable TextOpening to wrap the text of the Wrapper instance.

closing:TextClosing

The closing chars of a generic type variable TextClosing to wrap the text of the Wrapper instance.

Return type

Wrapped<Opening, Wrapped<TextOpening, Text, TextClosing>, Closing>

The return type is the generic type Wrapped that takes generic type variables Opening, Text and Closing.

Returns

The return value is the primitive value with text wrapped by given opening and closing characters of generic type Wrapped.

Example usage

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

const longText = new Wrapper('{', '}', '{This is a long text}');

// Returns {{{This is a long text}}} of "{{{This is a long text}}}".
longText.wrapText('{', '}');

// Returns {<{This is a long text}>} of "{<{This is a long text}>}".
longText.wrapText('<', '>');

Last updated