textWrap()

Wrapper.prototype.textWrap()

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

wrapper.class.ts
public textWrap<TextOpening extends string, TextClosing extends string>(
  opening: TextOpening,
  closing: TextClosing
): Wrapped<TextOpening, Text, TextClosing> {
  return new Wrap(opening, closing, this.text).valueOf();
}

Generic type variables

TextOpeningextendsstring

A generic type variable constrained by the string, by default of the value captured from the provided opening indicates the type of the opening chars in generic type Wrapped via return type.

TextClosingextendsstring

A generic type variable constrained by the string, by default of the value captured from the provided closing indicates the type of the closing chars in generic type Wrapped via return type.

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<TextOpening, Text, TextClosing>

The return type is generic type Wrapped that takes generic type variables TextOpening, Text and TextClosing.

Returns

The return value is the text wrapped by given opening and closing chars 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}}.
longText.valueOf();

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

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

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

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

Last updated