★ wrap()
Wrapper.prototype.wrap()
Wrapper.prototype.wrap()The method wraps the primitive value of a specified Wrapper object by its opening and closing chars, or the given opening and closing chars.
public wrap<
CustomOpening extends string = Opening,
CustomClosing extends string = Closing
>(
opening: CustomOpening = this.opening as any,
closing: CustomClosing = this.closing as any
): Wrapped<CustomOpening, Wrapped<Opening, Text, Closing>, CustomClosing> {
return new Wrap(opening, closing, this.valueOf()).valueOf();
}Generic type variables
CustomOpeningextendsstring=Opening
CustomOpeningextendsstring=OpeningA generic type variable constrained by the string indicates the captured type of the supplied opening parameter and the Opening type in the generic type Wrapped via return type, by default generic type variable Opening of the Wrapper object.
CustomClosingextendsstring=Closing
CustomClosingextendsstring=ClosingA generic type variable constrained by the string indicates the captured type of the supplied closing parameter and the Closing type in the generic type Wrapped via return type, by default generic type variable Closing of the Wrapper object.
Parameters
opening:CustomOpening
opening:CustomOpeningOptional opening chars of a generic type variable CustomOpening to wrap the primitive value of the Wrapper instance.
closing:CustomClosing
closing:CustomClosingOptional closing chars of a generic type variable CustomClosing to wrap the primitive value of the Wrapper instance.
Return type
Wrapped<CustomOpening, Wrapped<Opening, Text, Closing>, CustomClosing>
Wrapped<CustomOpening, Wrapped<Opening, Text, Closing>, CustomClosing> The return type is the generic type Wrapped that takes generic type variables Opening, Text and Closing.
Returns
The return value is a primitive value wrapped by the opening and closing chars of the Wrapper instance or the given opening and closing chars.
Example usage
// Example usage.
import { Wrapper } from '@angular-package/wrapper';
const longText = new Wrapper('{', '}', '{This is a long text}');
// Returns {{{This is a long text}}}.
longText.wrap();
// Returns {{This is a long text}}.
longText.wrap('', '');Last updated
Was this helpful?