# Wrapped() constructor

## `Wrapped()`

Creates a new instance of [`Wrapped`](https://docs.angular-package.dev/text/wrapper/wrapped) with the specified text and wrap.

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

```typescript
constructor(text: Text, wrap: Wrap<Opening, Closing>) {
  super(Wrapped.template`${text}${wrap}`);
  this.#closing = wrap.closing;
  this.#opening = wrap.opening;
  this.#text = text;
}
```

{% endcode %}

<table><thead><tr><th>Generic type variables</th><th data-hidden>Name</th></tr></thead><tbody><tr><td><p><strong><code>Text extends string</code></strong></p><p>​A generic type variable constrained by a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String"><code>string</code></a> by default of the value captured from the provided <code>text</code> parameter indicates the text type of <a href=""><code>Wrapped</code></a> via a new instance.</p></td><td><code>Chars</code></td></tr><tr><td><p><strong><code>Opening extends string</code></strong></p><p>​A generic type variable constrained by a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String"><code>string</code></a> by default of the value captured from the provided <code>wrap</code> parameter indicates the opening type of <a href=""><code>Wrapped</code></a> via a new instance.</p></td><td></td></tr><tr><td><p><strong><code>Closing extends string</code></strong></p><p>​A generic type variable constrained by a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String"><code>string</code></a> by default of the value captured from the provided <code>wrap</code> parameter indicates the closing type of <a href=""><code>Wrapped</code></a> via a new instance.</p></td><td></td></tr></tbody></table>

#### Parameters

<table><thead><tr><th width="173.44477578337126">Name: type</th><th>Description</th></tr></thead><tbody><tr><td><code>text: Text</code></td><td>The value of a generic type variable <code>Text</code> to be wrapped with a given <code>wrap</code>.</td></tr><tr><td><code>wrap: Wrap&#x3C;Opening, Closing></code></td><td>An instance of <a href="../wrap"><code>Wrap</code></a> to wrap a given <code>text</code>.</td></tr></tbody></table>

#### Returns

The **return value** is a new instance of [`Wrapped`](https://docs.angular-package.dev/text/wrapper/wrapped) with the primitive value of the provided `text` if set properly, otherwise with an empty `string`.

#### Example usage

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

const wrap = new Wrap(`[`, `]`);

// Returns Wrapped {'[[OH no, you wrapped me]]'}
new Wrapped(`[OH no, you wrapped me]`, wrap);

// Returns Wrapped{'[]'}
new Wrapped(null as any, wrap);
```
