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
  • Wrap()
  • Parameters
  • Returns
  • Example usage

Was this helpful?

  1. Wrap {}

★ Constructor

PreviousGeneric type variablesNextAccessors

Last updated 3 years ago

Was this helpful?

Wrap()

Creates a new instance of the and chars and optional to wrap.

wrap.class.ts
constructor(opening: Opening, closing: Closing, text: Text = '' as Text) {
  super(`${opening}${text}${closing}`);
  this.#closing = String(closing) as Closing;
  this.#text = String(text) as Text;
  this.#opening = String(opening) as Opening;
}

Parameters

opening:

Opening characters of the generic type variable placed before the given . An empty indicates that for the and methods, the chars are , returning false.

closing:

Closing characters of the generic type variable placed after the given . An empty indicates that for the and methods, the chars are , returning false.

text:=''

An optional text placed between the given and chars on the ${Opening}${Text}${Closing}.

Returns

Example usage

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

// Returns Wrap{'[]'}
new Wrap('[', ']');

// Returns Wrap{'nullnull'}
new Wrap(null as any, null as any);

The return value is a new instance of with the of the provided , , and the optional .

Wrap
opening
closing
text
Opening
Opening
text
string
hasOpening()
isWrapped()
opening
undefined
Closing
Closing
text
string
hasClosing()
isWrapped()
closing
undefined
Text
opening
closing
template literal
Wrap
primitive value
opening
closing
text