Wrapper
PackagesTwitterGitHub
v1.0.x
v1.0.x
  • Introduction
  • ❤ Benefits
    • Explanation
    • Designing
  • General concepts
  • Getting started
    • Skeleton
    • Installation
      • npm
    • Public API
    • Basic concepts
  • Wrap {}
    • Overview
    • Generic type variables
    • ★ Constructor
    • Accessors
      • closing
      • opening
      • text
      • [Symbol.toStringTag]
    • Properties
      • #closing
      • #opening
      • #text
    • Methods
      • Static
        • hasClosing()
        • hasOpening()
        • isWrap()
      • Instance
        • getClosing()
        • getOpening()
        • getText()
        • hasClosing()
        • hasOpening()
        • hasText()
        • isWrapped()
        • ★ replaceClosing()
        • ★ replaceOpening()
        • ★ replaceText()
        • toString()
        • valueOf()
    • Example usage
  • Wrapper {}
    • Overview
    • Generic type variables
    • Constructor
    • Accessors
      • [Symbol.toStringTag]
    • Methods
      • Static
        • define()
        • isWrapper()
        • replaceClosing()
        • replaceOpening()
        • unwrap()
      • Instance
        • isClosingIn()
        • isOpeningIn()
        • replaceClosingIn()
        • replaceOpeningIn()
        • removeWrapIn()
        • textReplaceClosing()
        • textReplaceOpening()
        • ⚠ textHasClosing()
        • ⚠ textHasOpening()
        • textUnwrap()
        • textWrap()
        • toArray()
        • toWrap()
        • unwrap()
        • unwrapText()
        • ★ wrap()
        • ★ wrapOn()
        • ★ wrapText()
    • Example usage
  • Type
    • Wrapped
  • Change log
    • Keep a changelog
    • CHANGELOG.md
    • v1.0.0
  • GIT
    • Commit
    • Semantic Versioning
  • License
    • MIT
  • Contact
    • ⋯ Chat
    • @ Email
  • Donate
    • ฿ Cryptocurrency
    • $ Fiat
Powered by GitBook
On this page
  • Wrapper.unwrap()
  • Parameters
  • Returns
  • Example usage

Was this helpful?

  1. Wrapper {}
  2. Methods
  3. Static

unwrap()

PreviousreplaceOpening()NextInstance

Last updated 3 years ago

Was this helpful?

Wrapper.unwrap()

The method returns the given without the given and chars.

wrapper.class.ts
public static unwrap(text: string, opening = '', closing = ''): string {
  return (
    (text = this.replaceClosing(text, closing, '')),
    (text = this.replaceOpening(text, opening, '')),
    text
  );
}

Parameters

text: string

The text of the from which given and chars are removed.

opening: string

The opening chars of the to be removed in the given .

closing: string

The closing chars of the to be removed in the given .

Returns

Example usage

// Example usage.
import { Wrapper } from '@angular-package/wrapper';

const quote = new Wrapper('[', ']', 'quote');

// Returns quote of string.
Wrapper.unwrap(quote.valueOf(), '[', ']');

// Returns [quote] of string.
Wrapper.unwrap(quote.valueOf(), '[[', ']]');

The return value is the given of type without the given and chars or unchanged if it does not contain the given and chars.

text
opening
closing
string
opening
closing
string
text
string
text
text
string
opening
closing
text
opening
closing