★ Constructor
Wrap()
Wrap()
Creates a new Wrap
instance of the opening
and closing
chars and optional text
to wrap.
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 characters of the generic type variable Opening
placed before the given text
. An empty string
indicates that for the hasOpening()
and isWrapped()
methods, the opening
chars are undefined
, returning false
.
Closing characters of the generic type variable Closing
placed after the given text
. An empty string
indicates that for the hasClosing()
and isWrapped()
methods, the closing
chars are undefined
, returning false
.
An optional text placed between the given opening
and closing
chars on the template literal ${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
// Example usage.
import { Wrap } from '@angular-package/wrapper';
// Returns Wrap{'[]'}
new Wrap('[', ']');
// Returns Wrap{'nullnull'}
new Wrap(null as any, null as any);
Last updated
Was this helpful?