> For the complete documentation index, see [llms.txt](https://docs.angular-package.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.angular-package.dev/text/wrapper/wrapped/wrapped-constructor.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
