Wrap() constructor

Wrap()

Creates a new Wrap instance of the opening and closing chars and optional text to wrap.

wrap.class.ts
constructor(opening: Opening, closing: Closing, text: Text = '' as Text) {
  super(`${opening}${text}${closing}`);
  this.#closing = String(closing) as Closing;
  this.#text = String(text) as Text;
  this.#opening = String(opening) as Opening;
}

Parameters

Name: type
Description

opening: Opening

Opening characters of the generic type variable Opening placed before the given text.

closing: Closing

Closing characters of the generic type variable Closing placed after the given text.

text: Text = ''

An optional text placed between the given opening and closing chars on the template ${Opening}${Text}${Closing}.

Returns

The return value is a new instance of Wrap with the primitive value of the provided opening, closing, and the optional text.

Usage

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

// Returns Wrap{'[]'}
new Wrap('[', ']');

// Returns Wrap{'nullnull'}
new Wrap(null as any, null as any);

Last updated