★ 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

opening:Opening

Opening characters of the generic type variable Opening placed before the given text. An empty stringarrow-up-right indicates that for the hasOpening() and isWrapped() methods, the opening chars are undefinedarrow-up-right, returning false.

closing:Closing

Closing characters of the generic type variable Closing placed after the given text. An empty stringarrow-up-right indicates that for the hasClosing() and isWrapped() methods, the closing chars are undefinedarrow-up-right, returning false.

text:Text=''

An optional text placed between the given opening and closing chars on the template literalarrow-up-right ${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.

Example usage

Last updated