unwrapText()

Wrapper.prototype.unwrapText()

The method returns the primitive value of a specified Wrapper object with text unwrapped from the opening and closing chars of the Wrapper instance or given opening and closing chars.

wrapper.class.ts
public unwrapText(
  opening: string = this.opening,
  closing: string = this.closing
): string {
  return `${this.opening}${Wrapper.unwrap(this.text, opening, closing)}${
    this.closing
  }`;
} 

Parameters

opening: string

Optional opening chars of string type to remove from the beginning of the text of the Wrapper instance.

closing: string

Optional closing chars of string type to remove from the end of the text of the Wrapper instance.

Returns

The return value is the primitive value of string type with text unwrapped from the opening and closing chars of the Wrapper object 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.unwrapText();

// Returns {{This is a long text}}.
longText.unwrapText('', '');

// Returns {This is a long text}}.
longText.unwrapText('{', '');

// Returns {{This is a long text}.
longText.unwrapText('', '}');

// Returns {{This is a long text}}.
longText.unwrapText('{{', '}}');

Last updated