> 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/static-methods.md).

# Static methods

## Public

### `Wrapped.isWrapped()`

The static method checks whether the provided `value` of any type is an instance of [`Wrapped`](/text/wrapper/wrapped.md).

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

```typescript
public static isWrapped<
  Text extends string,
  Opening extends string = string,
  Closing extends string = string
>(
  value: any,
  opening?: Opening,
  closing?: Closing
): value is Wrapped<Text, Opening, Closing> {
  return isInstance(value, Wrapped)
    ? isStringType(opening) && isStringType(closing)
      ? closing === value.closing && opening === value.opening
      : isStringType(opening)
      ? opening === value.opening
      : isStringType(closing)
      ? closing === value.closing
      : true
    : false;
}
```

{% 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> indicates the text type of <a href="/pages/KWQPnnFl0P7qlEW1NeKu"><code>Wrapped</code></a> in the return type.</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 the <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>opening</code> indicates the opening type of a checked <a href="/pages/KWQPnnFl0P7qlEW1NeKu"><code>Wrapped</code></a> instance.</p></td><td></td></tr><tr><td><p><strong><code>Closing extends string</code></strong></p><p>A generic type variable constrained by the <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>closing</code> indicates the closing type of a checked <a href="/pages/KWQPnnFl0P7qlEW1NeKu"><code>Wrapped</code></a> instance.</p></td><td></td></tr></tbody></table>

#### Parameters

| Name: type          | Description                                                                               |
| ------------------- | ----------------------------------------------------------------------------------------- |
| `value: any`        | The value of any type to test against the [`Wrapped`](/text/wrapper/wrapped.md) instance. |
| `opening?: Opening` | An optional opening of the `wrap` to check if the given `value` contains.                 |
| `closing?: Closing` | An optional closing of the `wrap` to check if the given `value` contains.                 |

#### Returns

| Return type                                                                                                                                                                                                                                                                                                                                                                            |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong><code>value is Wrapped\<Text, Opening, Closing></code></strong></p><p>The return type is a <code>boolean</code> indicating the <code>value</code> parameter is an instance of <a href="/pages/KWQPnnFl0P7qlEW1NeKu">Wrapped</a> that takes a generic type variable <code>Opening</code> and <code>Closing</code> of the wrap and <code>Text</code> of the wrapped text.</p> |

The **return value** is a [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) indicating whether the value is the [`Wrapped`](/text/wrapper/wrapped.md) instance of any or given wrap.

#### Example usage

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

// Define the wrapped.
const wrapped = new Wrapped(`[Oh no, I am wrapped]`, new Wrap('[', ']'));

// Returns `true`
Wrapped.isWrapped(wrapped, new Wrap('[', ']'));
```

### `Wrapped.template()`

The static "tag" method builds the wrapped text of a `string` type on the template literal. It consists of a `text` and an instance of [`Wrap`](/text/wrapper/wrap.md).

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

```typescript
public static template(
  template: TemplateStringsArray,
  ...values: any[]
): string {
  let text, wrap;
  return (
    ([text, wrap] = values),
    `${Wrap.isWrap(wrap) ? wrap.opening : ''}${template[0]}${text || ''}${
      Wrap.isWrap(wrap) ? wrap.closing : ''
    }`
  );
}
```

{% endcode %}

#### Parameters

| Name: type                       | Description                                                                                                                            |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `template: TemplateStringsArray` | An array of `string` values where the first element is a text between opening and closing.                                             |
| `...values: any[]`               | A rest parameter of expressions, where the first element is the text and the second is an instance of [`Wrap`](/text/wrapper/wrap.md). |

#### Returns

The **return value** is a `string` the wrapped text, or an empty `string` if elements of the provided `values` are not `string`.

#### Example usage

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

// Define.
const wrap = new Wrap('[[[[', ']]]]');

// Returns [[[[prefix-text to be wrapped]]]]
Wrapped.template`prefix-${'text to be wrapped'}${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/static-methods.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.
