# define()

## `Wrapper.define()`

Defines a new [`Wrapper`](https://wrapper.angular-package.dev/wrapper) instance with the provided [`opening`](#opening-opening), [`closing`](#closing-closing) chars, and optional [`text`](#text-text).

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

```typescript
public static define<
  Opening extends string,
  Closing extends string,
  Text extends string = ''
>(
  opening: Opening,
  closing: Closing,
  text?: Text
): Wrapper<Opening, Text, Closing> {
  return new this(opening, closing, text);
}
```

{% endcode %}

### Generic type variables

#### <mark style="color:green;">**`Opening`**</mark>**`extends`**<mark style="color:green;">**`string`**</mark>

A generic type variable constrained by the [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string), by default of the value captured from the provided [`opening`](#opening-opening) indicates the type of the opening in the [`Wrapper`](https://wrapper.angular-package.dev/wrapper) via [return type](#return-type).

#### <mark style="color:green;">**`Closing`**</mark>**`extends`**<mark style="color:green;">**`string`**</mark>

A generic type variable constrained by the [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string), by default of the value captured from the provided [`closing`](#closing-closing) indicates the type of the closing in the [`Wrapper`](https://wrapper.angular-package.dev/wrapper) via [return type](#return-type).

#### <mark style="color:green;">**`Text`**</mark>**`extends`**<mark style="color:green;">**`string`**</mark>**`=`**<mark style="color:green;">**`''`**</mark>

A generic type variable constrained by the [`string`](https://www.typescriptlang.org/docs/handbook/basic-types.html#string), by default of the value captured from the provided [`text`](#text-text) indicates the type of the text in the [`Wrapper`](https://wrapper.angular-package.dev/wrapper) via [return type](#return-type).

### Parameters

#### `opening: Opening`

The **opening** chars of generic type variable [`Opening`](#openingextendsstring) for new [`Wrapper`](https://wrapper.angular-package.dev/wrapper) instance.

#### `closing: Closing`

The **closing** chars of generic type variable [`Closing`](#closingextendsstring) for new [`Wrapper`](https://wrapper.angular-package.dev/wrapper) instance.

#### `text?: Text`

An optional **text** of generic type variable [`Text`](#textextendsstring) for new [`Wrapper`](https://wrapper.angular-package.dev/wrapper) instance.

### Return type

#### `Wrapper<Opening, Text, Closing>`

The **return type** is the [`Wrapper`](https://wrapper.angular-package.dev/wrapper) object that takes generic type variables [`Opening`](#openingextendsstring), [`Text`](#textextendsstring), and [`Closing`](#closingextendsstring).

### Returns

The **return value** is the [`Wrapper`](https://wrapper.angular-package.dev/wrapper) instance of given [`opening`](#opening-opening), [`closing`](#closing-closing) chars, and optional [`text`](#text-text).

## Example usage

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

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

// Returns Wrapper {'!!'}
// of type Wrapper<"!", "", "!">
Wrapper.define('!', '!');

// Returns Wrapper {'"This is quoted text"'}
// of type Wrapper<"\"", "This is quoted text", "\"">
Wrapper.define('"', '"', 'This is quoted text');
```
