angular-package
TwitterGitHub
Wrapper
Wrapper
  • 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
  • More versions
Powered by GitBook
On this page
  • Wrapper.replaceClosing()
  • Parameters
  • Returns
  • Example usage
  • Single bracket
  • Triple bracket

Was this helpful?

  1. Wrapper {}
  2. Methods
  3. Static

replaceClosing()

PreviousisWrapper()NextreplaceOpening()

Last updated 3 years ago

Was this helpful?

Wrapper.replaceClosing()

Replaces given chars with a given at the end of the given .

wrapper.class.ts
public static replaceClosing(
  text: string,
  closing: string,
  replaceValue: string
): string {
  return this.hasClosing(text, closing)
    ? text.slice(0, -closing.length) + replaceValue
    : text;
}

Parameters

text: string

The text of type in which given characters are replaced by a given replacement .

closing: string

The closing chars of the to replace by a given replacement value at the end of the given .

replaceValue: string

Returns

Example usage

Single bracket

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

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

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

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

Triple bracket

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

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

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

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

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

// Returns [[[quote] style="" of string.
Wrapper.replaceClosing(quote.valueOf(), quote.closing, ' style=""');

The replacement value of a type for the given characters in the given .

The return value is the given of type with a replaced chars by a given or the specified unchanged if it does not contain the given chars.

string
string
closing
replacement value
text
closing
value
text
string
closing
text
string
text
closing
replacement value
text
closing