# textWrap()

## `Wrapper.prototype.textWrap()`

The method returns the [`text`](https://wrapper.angular-package.dev/wrap/accessors/text) of the [`Wrapper`](https://wrapper.angular-package.dev/wrapper) object wrapped by the given [`opening`](#opening-textopening) and [`closing`](#closing-textclosing) chars.

{% code title="wrapper.class.ts" %}

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

{% endcode %}

### Generic type variables

#### <mark style="color:green;">**`TextOpening`**</mark>**`extends`**<mark style="color:green;">**`string`**</mark>

A generic type variable constrained by the [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string), by default of the value captured from the provided [`opening`](#opening-textopening) indicates the type of the opening chars in generic type [`Wrapped`](https://wrapper.angular-package.dev/type/wrapped)  via [return type](#return-type).

#### <mark style="color:green;">**`TextClosing`**</mark>**`extends`**<mark style="color:green;">**`string`**</mark>

A generic type variable constrained by the [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string), by default of the value captured from the provided [`closing`](#closing-textclosing) indicates the type of the closing chars in generic type [`Wrapped`](https://wrapper.angular-package.dev/type/wrapped) via [return type](#return-type).

### Parameters

#### `opening: TextOpening`

The **opening** chars of a generic type variable [`TextOpening`](#textopeningextendsstring) to wrap the [`text`](https://wrapper.angular-package.dev/wrap/accessors/text) of the [`Wrapper`](https://wrapper.angular-package.dev/wrapper) instance.

#### `closing: TextClosing`

The **closing** chars of a generic type variable [`TextClosing`](#textclosingextendsstring) to wrap the [`text`](https://wrapper.angular-package.dev/wrap/accessors/text) of the [`Wrapper`](https://wrapper.angular-package.dev/wrapper) instance.

### Return type

#### `Wrapped<TextOpening, Text, TextClosing>`

The **return type** is generic type [`Wrapped`](https://wrapper.angular-package.dev/type/wrapped) that takes generic type variables [`TextOpening`](#textopeningextendsstring), [`Text`](https://wrapper.angular-package.dev/generic-type-variables#wrapper-less-than...-text-...greater-than) and [`TextClosing`](#textclosingextendsstring).

### Returns

The **return value** is the [`text`](https://wrapper.angular-package.dev/wrap/accessors/text) wrapped by given [`opening`](#opening-textopening) and [`closing`](#closing-textclosing) chars of generic type [`Wrapped`](https://wrapper.angular-package.dev/type/wrapped).

## Example usage

```typescript
// 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('{', '}');
```
