# Wrapped() constructor

## `Wrapped()`

Creates a new instance of [`Wrapped`](/text/wrapper/wrapped.md) 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="/pages/KWQPnnFl0P7qlEW1NeKu"><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="/pages/KWQPnnFl0P7qlEW1NeKu"><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="/pages/KWQPnnFl0P7qlEW1NeKu"><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="/pages/vlRmumtdkPHxEUrU51WO"><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`](/text/wrapper/wrapped.md) 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);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.angular-package.dev/text/wrapper/wrapped/wrapped-constructor.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
