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

# Static methods

## Public

### `Wrapper.define()`

Defines a new [`Wrapper`](/text/wrapper/basic-concepts.md) instance consisting of the allowed opening and closing.

{% hint style="info" %}
**Good to know:** The opening and closing parameters are filtered by the [allowed chars](https://docs.angular-package.dev/text/wrapper/wrapper/pages/BLs9IJkpS4vur3ICqHpl#wrapper.allowedchars).
{% endhint %}

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

```typescript
public static define<Opening extends string, Closing extends string>(
  opening: Opening,
  closing: Closing
): Wrapper<Opening, Closing> {
  return new this(
    this.allowedChars.filterText(opening),
    this.allowedChars.filterText(closing)
  );
}
```

{% endcode %}

<table><thead><tr><th>Generic type variables</th><th data-hidden>Name</th></tr></thead><tbody><tr><td><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>opening</code> indicates the type of the opening in the <a href="/pages/OnxhYXL7HocXsHa9qO3M"><code>Wrapper</code></a> via return type.</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://www.typescriptlang.org/docs/handbook/basic-types.html#string"><code>string</code></a>, by default of the value captured from the provided <code>closing</code> indicates the type of the closing in the <a href="/pages/OnxhYXL7HocXsHa9qO3M"><code>Wrapper</code></a> via return type.</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>opening: Opening</code></td><td>The allowed opening of the wrap of a generic type variable <code>Opening</code>.</td></tr><tr><td><code>closing: Closing</code></td><td>The allowed closing of the wrap of a generic type variable <code>Closing</code>.</td></tr></tbody></table>

#### Returns

The **return value** is a new [`Wrapper`](/text/wrapper/basic-concepts.md) instance of given opening and closing.

#### Example usage

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

// Returns Wrap {'()'}
Wrapper.define('(', ')');

// Returns Wrapper{''}, char ! is not allowed.
Wrapper.define('!', '!');
```

### `Wrapper.getAllowedChars()`

Gets the allowed characters of the [`AllowedChars`](/text/main/allowedchars.md) type from the static [`Wrapper`](/text/wrapper/wrapper.md).

{% hint style="info" %}
**Good to know:** The method refers to a private static property [`allowedChars`](https://docs.angular-package.dev/text/wrapper/wrapper/pages/BLs9IJkpS4vur3ICqHpl#wrapper.allowedchars) which is the default value for filtering the wrap in the static [`define()`](#wrapper.define), [`setWrap()`](#wrapper.setwrap), [`wrapText()`](#wrapper.wraptext) methods.
{% endhint %}

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

```typescript
public static getAllowedChars(): AllowedChars {
  return this.allowedChars;
}
```

{% endcode %}

#### Returns

The **return value** is a an [`AllowedChars`](/text/main/allowedchars.md) pattern of allowed characters.

#### Example usage

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

// Returns the default /([\[\]\(\)<>{}])/g
Wrapper.getAllowedChars();
```

### `Wrapper.getWrap()`

Gets an instance of [`Wrap`](/text/wrapper/wrap.md) stored in the static [`Wrapper`](/text/wrapper/wrapper.md).

{% hint style="info" %}
**Good to know:** The method refers to a private static property [wrap](https://docs.angular-package.dev/text/wrapper/wrapper/pages/BLs9IJkpS4vur3ICqHpl#wrapper.wrap) that is used by the static [`wrapText()`](#wrapper.wraptext) method for wrapping the text.
{% endhint %}

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

```typescript
public static getWrap<
  Opening extends string = string,
  Closing extends string = string
>(): Wrap<Opening, Closing> {
  return this.wrap as Wrap<Opening, Closing>;
}
```

{% endcode %}

<table><thead><tr><th>Generic type variables</th><th data-hidden>Name</th></tr></thead><tbody><tr><td><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> indicates the type of the opening in the <a href="/pages/vlRmumtdkPHxEUrU51WO"><code>Wrap</code></a> via return type.</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://www.typescriptlang.org/docs/handbook/basic-types.html#string"><code>string</code></a> indicates the type of the closing in the <a href="/pages/vlRmumtdkPHxEUrU51WO"><code>Wrap</code></a> via return type.</p></td><td></td></tr></tbody></table>

#### Returns

The **return value** is an instance of [`Wrap`](/text/wrapper/wrap.md).

#### Example usage

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

// Returns `Wrap {'[]'}` of type `Wrap<string, string>`
Wrapper.getWrap();

// Returns `Wrap {'[]'}` of type `Wrap<"[", "]">`
Wrapper.getWrap<'[', ']'>();
```

### `Wrapper.isWrapper()`

The method checks if the value of any type is an instance of the [`Wrapper`](/text/wrapper/basic-concepts.md).

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

```typescript
public static isWrapper<Opening extends string, Closing extends string>(
  value: any,
  opening?: Opening,
  closing?: Closing
): value is Wrapper<Opening, Closing> {
  return isInstance(value, this) && super.isWrap(value, opening, closing);
}
```

{% endcode %}

<table><thead><tr><th>Generic type variables</th><th data-hidden>Name</th></tr></thead><tbody><tr><td><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>opening</code> indicates the type of the opening in the <a href="/pages/OnxhYXL7HocXsHa9qO3M"><code>Wrapper</code></a> via return type.</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://www.typescriptlang.org/docs/handbook/basic-types.html#string"><code>string</code></a>, by default of the value captured from the provided <code>closing</code> indicates the type of the closing in the <a href="/pages/OnxhYXL7HocXsHa9qO3M"><code>Wrapper</code></a> via return type.</p></td><td></td></tr></tbody></table>

#### Parameters

| Name: type          | Description                                                                                                                                                                   |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `value: any`        | The value of any type to test against the instance of [`Wrapper`](/text/wrapper/basic-concepts.md).                                                                           |
| `opening?: Opening` | An optional [`wrap opening`](https://docs.angular-package.dev/text/wrapper/wrapper/pages/QTYxQh3MKwTJRj5pYA28#wrap.prototype.opening) to check if the given `value` contains. |
| `closing?: Closing` | An optional [`wrap closing`](https://docs.angular-package.dev/text/wrapper/wrapper/pages/QTYxQh3MKwTJRj5pYA28#wrap.prototype.closing) to check if the given `value` contains. |

#### Returns

| Return type                                                                                                                                                                                  |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong><code>value is Wrapper</code></strong></p><p>The return type indicates the <code>value</code> is the <a href="/pages/OnxhYXL7HocXsHa9qO3M"><code>Wrapper</code></a> instance.</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 [`Wrapper`](/text/wrapper/basic-concepts.md).

#### Example usage

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

const tagWrapper = new Wrapper('[', ']');

// Returns true confirming the type Wrapper<string>
Wrapper.isWrapper(tagWrapper);

// Returns true confirming the type Wrapper<"[]">
Wrapper.isWrapper<'[', ']'>(tagWrapper);

// Returns false denying the type Wrapper<"[]">
Wrapper.isWrapper<'[', ']'>(null as any);
```

### `Wrapper.setAllowedChars()`

The method sets the default pattern of allowed characters for static [`Wrapper`](/text/wrapper/basic-concepts.md).

{% hint style="info" %}
**Good to know:** The allowed characters refers to a private static [`allowedChars`](https://docs.angular-package.dev/text/wrapper/wrapper/pages/BLs9IJkpS4vur3ICqHpl#wrapper.allowedchars) property, which is the default value for filtering the wrap in the static [`define()`](#wrapper.define), [`setWrap()`](#wrapper.setwrap), [`wrapText()`](#wrapper.wraptext) methods.
{% endhint %}

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

```typescript
public static setAllowedChars(allowedChars: RegExp): typeof Wrapper {
  this.allowedChars = new AllowedChars(allowedChars);
  return this;
}
```

{% endcode %}

#### Parameters

<table><thead><tr><th width="173.44477578337126">Name: type</th><th>Description</th></tr></thead><tbody><tr><td><code>allowedChars: RegExp</code></td><td>The allowed characters of the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp"><code>RegExp</code></a> to set.</td></tr></tbody></table>

#### Returns

The **return value** is a static [`Wrapper`](/text/wrapper/basic-concepts.md).

#### Example usage

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

// Set the allowed chars for static `Wrapper`.
Wrapper.setAllowedChars(/[^<>]/g);

// Returns /[^<>]/g
Wrapper.getAllowedChars();
```

### `Wrapper.setWrap()`

Sets a new instance of [`Wrap`](/text/wrapper/wrap.md) into the static  [`Wrapper`](/text/wrapper/wrap.md). The wrap set by this method is used to wrap the text by the static [`wrapText()`](#wrapper.setwrap) method for wrapping the text.

{% hint style="info" %}
**Good to know:** The `opening` and `closing` parameters are filtered by the allowed characters of static [`Wrapper`](/text/wrapper/basic-concepts.md) set by the static method [`setAllowedChars()`](#wrapper.setallowedchars).
{% endhint %}

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

```typescript
public static setWrap<Opening extends string, Closing extends string>(
  opening: Opening,
  closing: Closing
): typeof Wrapper {
  this.wrap = new Wrap(
    this.allowedChars.filterText(opening),
    this.allowedChars.filterText(closing)
  );
  return this;
}
```

{% endcode %}

<table><thead><tr><th>Generic type variables</th><th data-hidden>Name</th></tr></thead><tbody><tr><td><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>opening</code> indicates the type of the <a href="/pages/vlRmumtdkPHxEUrU51WO"><code>Wrap</code></a> opening.</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://www.typescriptlang.org/docs/handbook/basic-types.html#string"><code>string</code></a>, by default of the value captured from the provided <code>closing</code> indicates the type of the <a href="/pages/vlRmumtdkPHxEUrU51WO"><code>Wrap</code></a> closing.</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>opening: Opening</code></td><td>The wrap opening of a generic type variable <code>Opening</code>.</td></tr><tr><td><code>closing: Closing</code></td><td>The wrap closing of a generic type variable <code>Closing</code>.</td></tr></tbody></table>

#### Returns

The **return value** is a static [`Wrapper`](/text/wrapper/basic-concepts.md).

#### Example usage

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

// Set the `Wrap`.
Wrapper.setWrap('<', '>');

// Returns Wrap {'<>'} of type `Wrap<string, string>`
Wrapper.getWrap();

// Returns Wrap {'<>'} of type `Wrap<"<", ">">`
Wrapper.getWrap<'<', '>'>();
```

### `Wrapper.wrapText()`

The static method [wraps](/text/wrapper/basic-concepts.md#wrap) the specified text with a stored [`Wrap`](/text/wrapper/wrap.md) instance in the static [`Wrapper`](/text/wrapper/basic-concepts.md) or with a given opening or closing.

{% hint style="info" %}
**Good to know:** The `opening` and `closing` parameters are filtered by the allowed chars of static [`Wrapper`](/text/wrapper/basic-concepts.md) set by the static method [`setAllowedChars()`](https://docs.angular-package.dev/text/wrapper/wrapper/pages/s91IbXXrbQGZ3f10bJU8#wrapper.setallowedchars).
{% endhint %}

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

```typescript
public static wrapText<
  Text extends string,
  Opening extends string,
  Closing extends string
>(
  text: Text,
  opening: Opening = this.wrap.opening as Opening,
  closing: Closing = this.wrap.closing as Closing
): Wrapped<Text, Opening, Closing> {
  return new this(opening, closing).wrapText(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 the <a href="https://www.typescriptlang.org/docs/handbook/basic-types.html#string"><code>string</code></a> indicates the type of the text in the <a href="/pages/KWQPnnFl0P7qlEW1NeKu"><code>Wrapped</code></a> via return type.</p></td><td></td></tr><tr><td><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>opening</code> indicates the type of the opening in the <a href="/pages/KWQPnnFl0P7qlEW1NeKu"><code>Wrapped</code></a> via return type.</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://www.typescriptlang.org/docs/handbook/basic-types.html#string"><code>string</code></a>, by default of the value captured from the provided <code>closing</code> indicates the type of the closing in the <a href="/pages/KWQPnnFl0P7qlEW1NeKu"><code>Wrapped</code></a> via return type.</p></td><td></td></tr></tbody></table>

#### Parameters

<table><thead><tr><th width="150">Name: type</th><th>Description</th></tr></thead><tbody><tr><td><code>text: Text</code></td><td>The text of a generic type variable <code>Text</code> to wrap it with a stored <a href="/pages/vlRmumtdkPHxEUrU51WO"><code>Wrap</code></a> in the static <a href="/pages/O5zJvtCr0bk2EDs7sRGG"><code>Wrapper</code></a> or provided allowed <code>chars</code>.</td></tr><tr><td><code>opening: Opening</code></td><td>An optional wrap opening of a generic type variable <code>Opening</code> to wrap the given <code>text</code>. If the <code>opening</code> is not provided, then the opening from the <code>Wrap</code> instance of static <a href="/pages/OnxhYXL7HocXsHa9qO3M"><code>Wrapper</code></a> is used.</td></tr><tr><td><code>closing: Closing</code></td><td>An optional wrap closing of a generic type variable <code>Closing</code> to wrap the given <code>text</code>. If the <code>closing</code> is not provided, then the closing from the <code>Wrap</code> instance of static <a href="/pages/OnxhYXL7HocXsHa9qO3M"><code>Wrapper</code></a> is used.</td></tr></tbody></table>

#### Returns

The **return value** is a new [`Wrapped`](/text/wrapper/wrapped.md) instance of given text.

#### Example usage

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

// Set the wrap.
Wrapper.setWrap('<', '>');

// Returns Wrapped {'<Lorem Ipsum>'} of Wrapped<"Lorem Ipsum ", string, string>
Wrapper.wrapText(`Lorem Ipsum `);

// Returns Wrapped {'[[[Lorem Ipsum>'} of Wrapped<"Lorem Ipsum ", "[[[", string>
Wrapper.wrapText(`Lorem Ipsum `, '[[[');

// Returns Wrapped {'<Lorem Ipsum]]]'} of Wrapped<"Lorem Ipsum ", string, "]]]">
Wrapper.wrapText(`Lorem Ipsum `, undefined, ']]]');
```


---

# 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:

```
GET https://docs.angular-package.dev/text/wrapper/wrapper/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.
