# ★ Constructor

## `Wrap()`

Creates a new [`Wrap`](https://wrapper.angular-package.dev/wrap) instance of the [`opening`](#opening-opening) and [`closing`](#closing-closing) chars and optional [`text`](#text-text) to wrap.&#x20;

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

```typescript
constructor(opening: Opening, closing: Closing, text: Text = '' as Text) {
  super(`${opening}${text}${closing}`);
  this.#closing = String(closing) as Closing;
  this.#text = String(text) as Text;
  this.#opening = String(opening) as Opening;
}
```

{% endcode %}

### Parameters

#### `opening:`[<mark style="color:green;">`Opening`</mark>](https://wrapper.angular-package.dev/generic-type-variables#wrap-opening)

Opening characters of the generic type variable [`Opening`](https://wrapper.angular-package.dev/generic-type-variables#wrap-opening) placed before the given [`text`](#text-text). An empty [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) indicates that for the [`hasOpening()`](https://wrapper.angular-package.dev/methods/instance/hasopening#wrap.prototype.hasopening) and [`isWrapped()`](https://wrapper.angular-package.dev/wrap/methods/instance/iswrapped) methods, the [`opening`](https://wrapper.angular-package.dev/wrap/accessors/opening) chars are [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined), returning `false`.

#### `closing:`[<mark style="color:green;">`Closing`</mark>](https://wrapper.angular-package.dev/generic-type-variables#wrap-closing)

Closing characters of the generic type variable [`Closing`](https://wrapper.angular-package.dev/generic-type-variables#wrap-closing) placed after the given [`text`](#text-text). An empty [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) indicates that for the [`hasClosing()`](https://wrapper.angular-package.dev/wrap/methods/instance/hasclosing) and [`isWrapped()`](https://wrapper.angular-package.dev/wrap/methods/instance/iswrapped) methods, the [`closing`](https://wrapper.angular-package.dev/wrap/accessors/closing) chars are [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined), returning `false`.

#### `text:`[<mark style="color:green;">`Text`</mark>](https://wrapper.angular-package.dev/generic-type-variables#wrap-less-than...-text-...greater-than)`=`<mark style="color:green;">`''`</mark>

An optional text placed between the given [`opening`](#opening-opening) and [`closing`](#closing-closing) chars on the [template literal](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html) `${Opening}${Text}${Closing}`.

### Returns

The **return value** is a new instance of [`Wrap`](https://wrapper.angular-package.dev/wrap) with the [primitive value](https://wrapper.angular-package.dev/wrap/methods/instance/valueof) of the provided [`opening`](#opening-opening), [`closing`](#closing-closing), and the optional [`text`](#text-text).

## Example usage

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

// Returns Wrap{'[]'}
new Wrap('[', ']');

// Returns Wrap{'nullnull'}
new Wrap(null as any, null as any);
```
