★ wrapOn()

Wrapper.prototype.wrapOn()

The method wraps the given text with the wrap, the opening, and closing chars of the Wrapper object.

wrapper.class.ts
public wrapOn<CustomText extends string = ''>(
  text: CustomText
): Wrapped<Opening, CustomText, Closing> {
  return new Wrap(this.opening, this.closing, text).valueOf();
}

Generic type variables

CustomTextextendsstring=''

A generic type variable constrained by the string indicates the captured type of the supplied text parameter and the value of the generic type variable Text in the generic type Wrapped via return type, by default an empty string.

Parameters

The text of generic type variable CustomText to wrap by the opening and closing chars of the Wrapper instance.

Return type

Wrapped<Opening, CustomText, Closing>

The return type is generic type Wrapped that takes generic type variables Opening, CustomText and Closing.

Returns

The return value is the given text wrapped by the opening and closing chars of the Wrapper object of the generic type Wrapped.

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.wrapOn('{This is a long text}');

// Returns <span color="red">.
new Wrapper('<', '>').wrapOn('span color="red"');

Last updated