# isWrapped()

## `Wrap.prototype.isWrapped()`

The method checks whether the [primitive value](https://wrapper.angular-package.dev/wrap/methods/instance/valueof) of the specified object is wrapped by the [opening](https://wrapper.angular-package.dev/wrap/accessors/opening) and [closing](https://wrapper.angular-package.dev/wrap/accessors/closing) chars of an instance or given [`opening`](#opening-string-this.-opening) and [`closing`](#closing-string-this.-closing) chars.

{% hint style="info" %}
If given `opening` or `closing` chars in the constructor are the **empty** `string`, the method returns **`false`**.
{% endhint %}

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

```typescript
public isWrapped(
  opening: string = this.#opening,
  closing: string = this.#closing
): boolean {
  return this.hasOpening(opening) && this.hasClosing(closing);
}
```

{% endcode %}

### Parameters

#### `opening: string = this.#opening`

Optional opening chars of a [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) type to check if the [primitive value](https://wrapper.angular-package.dev/wrap/methods/instance/valueof) contains them at the **beginning**. The default value is picked from the private [`#opening`](https://wrapper.angular-package.dev/wrap/properties/opening) property of an instance.

#### `closing: string = this.#closing`

Optional closing chars of a [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) type to check if the [primitive value](https://wrapper.angular-package.dev/wrap/methods/instance/valueof) contains them at the **end**. The default value is picked from the private [`#closing`](https://wrapper.angular-package.dev/wrap/properties/closing) property of an instance.

### Returns

The **return value** is a [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) indicating whether the object has both [`opening`](https://wrapper.angular-package.dev/wrap/accessors/opening) and [`closing`](https://wrapper.angular-package.dev/wrap/accessors/closing) chars or given [`opening`](#opening-string-this.-opening) and [`closing`](#closing-string-this.-closing) chars.

## Example usage

### Basic

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

// Returns true. Checks `[]`.
new Wrap(`[`, `]`, 'quote').isWrapped();

// Returns false.
// It's not wrapped cause of opening chars are an empty string.
new Wrap(``, `]`, 'quote').isWrapped();

// Returns false.
// It's not wrapped cause of closing chars are an empty string.
new Wrap(`[`, ``, 'quote').isWrapped();

// Returns false.
new Wrap(``, ``, 'quote').isWrapped();
```

### Given `opening`

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

// Returns true. Checks `[]`.
new Wrap(`[`, `]`, 'quote').isWrapped('[');

// Returns false.
new Wrap(`[`, `]`, 'quote').isWrapped('[', '');

// Returns false. Checks `<]`.
new Wrap(`[`, `]`, 'quote').isWrapped('<');

// Returns false.
// It's not wrapped cause of opening chars are an empty string.
new Wrap(``, `]`, 'quote').isWrapped('<');

// Returns false.
// It's not wrapped cause of closing chars are an empty string.
new Wrap(`[`, ``, 'quote').isWrapped('[');

// Returns false.
// It's not wrapped cause of closing chars are an empty string.
new Wrap(`[`, ``, 'quote').isWrapped('[', ''),
```

### Given `closing`

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

// Returns true. Checks `[]`.
new Wrap(`[`, `]`, 'quote').isWrapped(undefined, ']');

// Returns false. Checks `[>`.
new Wrap(`[`, `]`, 'quote').isWrapped(undefined, '>');

// Returns false.
// It's not wrapped cause of opening chars are an empty string.
new Wrap(``, `]`, 'quote').isWrapped(undefined, ']');

// Returns false.
// It's not wrapped cause of opening chars are an empty string.
new Wrap(``, `]`, 'quote').isWrapped(``, ']');
```

### Given `opening` and `closing` chars

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

// Returns false.
new Wrap(`[`, `]`, 'quote').isWrapped('[', ']');

// Returns false.
new Wrap(`[`, `]`, 'quote').isWrapped('[', '>');

// Returns false.
new Wrap(`[`, `]`, 'quote').isWrapped('<', ']');

// Returns false.
new Wrap(`[`, `]`, 'quote').isWrapped('<', '>');

// Returns false.
new Wrap(``, ``, 'quote').isWrapped('', '');
```


---

# 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://wrapper.angular-package.dev/wrap/methods/instance/iswrapped.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.
