Wrapped() constructor

Wrapped()

Creates a new instance of Wrapped with the specified text and wrap.

wrapped.class.ts
constructor(text: Text, wrap: Wrap<Opening, Closing>) {
  super(Wrapped.template`${text}${wrap}`);
  this.#closing = wrap.closing;
  this.#opening = wrap.opening;
  this.#text = text;
}
Generic type variables

Text extends string

​A generic type variable constrained by a string by default of the value captured from the provided text parameter indicates the text type of Wrapped via a new instance.

Opening extends string

​A generic type variable constrained by a string by default of the value captured from the provided wrap parameter indicates the opening type of Wrapped via a new instance.

Closing extends string

​A generic type variable constrained by a string by default of the value captured from the provided wrap parameter indicates the closing type of Wrapped via a new instance.

Parameters

Name: typeDescription

text: Text

The value of a generic type variable Text to be wrapped with a given wrap.

wrap: Wrap<Opening, Closing>

An instance of Wrap to wrap a given text.

Returns

The return value is a new instance of Wrapped with the primitive value of the provided text if set properly, otherwise with an empty string.

Example usage

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

const wrap = new Wrap(`[`, `]`);

// Returns Wrapped {'[[OH no, you wrapped me]]'}
new Wrapped(`[OH no, you wrapped me]`, wrap);

// Returns Wrapped{'[]'}
new Wrapped(null as any, wrap);

Last updated