# Static methods

## Public

### `Wrap.isWrap()`

The method checks if the value of any type is the [`Wrap`](/text/wrapper/wrap.md) instance of any or given opening and closing.

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

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

{% endcode %}

| Generic type variables                                                                                                                                                                                                                                                                                                                                                                                                             |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong><code>Opening extends string</code></strong></p><p>A generic type variable constrained by the <a href="https://www.typescriptlang.org/docs/handbook/basic-types.html#string"><code>string</code></a>, by default of the value captured from the provided <code>wrap</code> indicates the <code>Opening</code> type of the <a href="/pages/vlRmumtdkPHxEUrU51WO"><code>Wrap</code></a> instance via the return type.</p> |
| <p><strong><code>Closing extends string</code></strong></p><p>A generic type variable constrained by the <a href="https://www.typescriptlang.org/docs/handbook/basic-types.html#string"><code>string</code></a>, by default of the value captured from the provided <code>wrap</code> indicates the <code>Closing</code> type of the <a href="/pages/vlRmumtdkPHxEUrU51WO"><code>Wrap</code></a> instance via the return type.</p> |

#### Parameters

| Name: type          | Description                                                                                    |
| ------------------- | ---------------------------------------------------------------------------------------------- |
| `value: any`        | The value of any type to test against the `Wrap` instance of any or given opening and closing. |
| `opening?: Opening` | An optional wrap opening to check if the given `value` contains.                               |
| `closing?: Closing` | An optional wrap closing to check if the given `value` contains.                               |

#### Returns

| Return type                                                                                                                                                                                                                                                                                                                       |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong><code>value is Wrap\<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/vlRmumtdkPHxEUrU51WO"><code>Wrap</code></a> that takes a generic type variable <code>Opening</code> and <code>Closing</code>.</p> |

The **return value** is a [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) type indicating whether the value is an instance of `Wrap` of any or given opening and closing.

#### Example usage

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

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

// Returns true confirming the type Wrap<string, string>
Wrap.isWrap(tagWrap);

// Returns true confirming the type Wrap<"[", "]">
Wrap.isWrap(tagWrap, ['[', ']']);

// Returns true confirming the type Wrap<"[", "]">
Wrap.isWrap<'[', ']'>(tagWrap, ['[', ']']);

// Returns false by denying the value is Wrap<"(", ")">
Wrap.isWrap(tagWrap, ['(', ')']);

// Returns false by denying the value is Wrap<"[", "]">
Wrap.isWrap<'[', ']'>(null as any);

// Returns false by denying the value is Wrap<"[", "]">
Wrap.isWrap(null as any, ['[', ']']);
```

### `Wrap.template()`

The static "tag" method builds the wrap of a [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string) type on the template. With the added string before the expressions, it returns a wrapped string.

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

```typescript
public static template(
  template: TemplateStringsArray,
  ...values: string[]
): string {
  let opening, closing;
  if (areString(...values).every()) {
    return (
      ([opening, closing] = values), `${opening}${template[0]}${closing}`
    );
  }
  return ``;
}
```

{% endcode %}

#### Parameters

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

#### Returns

The **return value** is a [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string) the wrap, or an empty `string` if elements of the provided `values` are not `string`.

#### Example usage

```typescript
import { Wrap } from '@angular-package/text';

// Returns {{inside}}
Wrap.template`inside${'{{'}${'}}'}`;
```


---

# 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/wrap/static-methods.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.
