# Instance methods

## Public

### `Wrapper.prototype.isTextWrapped()`

The method checks if the provided `text` is wrapped with the wrap of the specified [`Wrapper`](https://docs.angular-package.dev/text/wrapper) object.

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

```typescript
public isTextWrapped<Text extends string>(text: Text): text is Text {
  return this.textHasClosing(text) && this.textHasOpening(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://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, confirms the text type via the return type.</p></td><td><code>Chars</code></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 <code>text</code> of a generic type variable <code>Text</code> to check whether it is wrapped.</td></tr></tbody></table>

#### Returns

The **return value** is a [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) indicating whether the provided `text` is wrapped.

#### Example usage

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

// Returns true of text is "[quote]"
new Wrapper(`[`, `]`).isTextWrapped(`[quote]`);
```

### `Wrapper.prototype.textHasClosing()`

Checks if the provided `text` has a closing of the specified [`Wrapper`](https://docs.angular-package.dev/text/wrapper) object.

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

```typescript
public textHasClosing<Text extends string>(text: Text): text is Text {
  return (
    isStringType(text) && text.slice(-this.closing.length) === this.closing
  );
}
```

{% 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://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, confirms the text type via the return type.</p></td><td><code>Chars</code></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 text to test against the existence of the <a href="../../wrap/instance-accessors#wrap.prototype.closing"><code>closing</code></a>.</td></tr></tbody></table>

#### Returns

The return value is a [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) indicating whether the given `text` has the closing of the wrap.

#### Example usage

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

// Returns true of text is "[quote]"
new Wrapper(`[`, `]`).textHasClosing(`[quote]`);
```

### `Wrapper.prototype.textHasOpening()`

Checks if the provided `text` has an opening of the specified [`Wrapper`](https://docs.angular-package.dev/text/wrapper) object.

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

```typescript
public textHasOpening<Text extends string>(text: Text): text is Text {
  return (
    isStringType(text) && text.slice(0, this.opening.length) === this.opening
  );
}
```

{% 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://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, confirms the text type via the return type.</p></td><td><code>Chars</code></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 text to test against the existence of the <a href="../../wrap/instance-accessors#wrap.prototype.opening"><code>opening</code></a>.</td></tr></tbody></table>

#### Returns

The **return value** is a [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) indicating whether the given `text` has the opening of the wrap.

#### Example usage

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

// Returns true of text is "[quote]"
new Wrapper(`[`, `]`).textHasOpening(`[quote]`);
```

### `Wrapper.prototype.unwrapText()`

Returns the unwrapped text, without the opening and closing of the [`Wrapper`](https://docs.angular-package.dev/text/wrapper/wrapper).

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

```typescript
public unwrapText(text: string): string {
  this.textHasClosing(text) &&
    (text = text.valueOf().slice(0, text.length - this.closing.length));
  this.textHasOpening(text) &&
    (text = text.valueOf().slice(this.opening.length));
  return text;
}
```

{% endcode %}

#### Parameters

<table><thead><tr><th width="173.44477578337126">Name: type</th><th>Description</th></tr></thead><tbody><tr><td><code>text: string</code></td><td>The text to unwrap.</td></tr></tbody></table>

#### Returns

The **return value** is the unwrapped text of a [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) if the opening or closing is found or the given `text`.

#### Example usage

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

// Define a new `Wrapper`.
const wrapper = new Wrapper('[', ']');

 // Returns [[There is a wrapped text]]
const unwrapped = wrapper.unwrapText('[[[There is a wrapped text]]]');

// Returns [There is a wrapped text]
wrapper.unwrapText(unwrapped);
```

### `Wrapper.prototype.wrapText()`

Wraps specific text with the wrap, the [`opening`](https://docs.angular-package.dev/text/wrap/instance-accessors#wrap.prototype.opening), and [`closing`](https://docs.angular-package.dev/text/wrap/instance-accessors#wrap.prototype.closing) of the [`Wrapper`](https://docs.angular-package.dev/text/wrapper) object.

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

```typescript
public wrapText<Text extends string>(
  text: Text
): Wrapped<Text, Opening, Closing> {
  return new Wrapped(text, this);
}
```

{% 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://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="../wrapped"><code>Wrapped</code></a> via the return type.</p></td><td><code>Chars</code></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 text of a generic type variable <code>Text</code>, to be wrapped.</td></tr></tbody></table>

#### Returns

The **return value** is a new instance of [`Wrapped`](https://docs.angular-package.dev/text/wrapper/wrapped) type consisting of the wrapped text.

#### Example usage

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

// Returns Wrapped {'[Lorem]'} of Wrapped<"Lorem", "[", "]">
new Wrapper('[', ']').wrapText('Lorem');

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