Wrapper
PackagesTwitterGitHub
Draft
Draft
  • Introduction
  • ❤ Benefits
    • Explanation
    • Designing
  • General concepts
  • Getting started
    • Skeleton
    • Installation
      • npm
    • Public API
    • Basic concepts
  • Wrap {}
    • Overview
    • Generic type variables
    • ★ Constructor
    • Accessors
      • get closing()
      • get opening()
      • get text()
      • get [Symbol.toStringTag]()
    • Properties
      • #closing
      • #opening
      • #text
    • Methods
      • ↓ Static
      • static hasClosing()
      • static hasOpening()
      • static isWrap()
      • ↓ Instance
      • getClosing()
      • getOpening()
      • getText()
      • hasClosing()
      • hasOpening()
      • hasText()
      • isWrapped()
      • ★ replaceClosing()
      • ★ replaceOpening()
      • ★ replaceText()
      • toString()
      • valueOf()
    • Example usage
  • Wrapper {}
    • Overview
    • Generic type variables
    • Constructor
    • Accessors
      • get [Symbol.toStringTag]()
    • Methods
      • ↓ Static
      • static define()
      • static isWrapper()
      • static replaceClosing()
      • static replaceOpening()
      • static 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
  • Social
    • Gettr
    • Twitter
    • YouTube
  • Contact
    • ⋯ Chat
    • @ Email
    • ✆ Phone
  • Donate
    • ฿ Cryptocurrency
    • $ Fiat
Powered by GitBook
On this page
  • Wrapper.prototype.wrap()
  • Generic type variables
  • Parameters
  • Return type
  • Returns
  • Example usage

Was this helpful?

Edit on GitHub
  1. Wrapper {}
  2. Methods

★ wrap()

PreviousunwrapText()Next★ wrapOn()

Last updated 3 years ago

Was this helpful?

Wrapper.prototype.wrap()

The method wraps the of a specified object by its and chars, or the given and chars.

wrapper.class.ts
public wrap<
  CustomOpening extends string = Opening,
  CustomClosing extends string = Closing
>(
  opening: CustomOpening = this.opening as any,
  closing: CustomClosing = this.closing as any
): Wrapped<CustomOpening, Wrapped<Opening, Text, Closing>, CustomClosing> {
  return new Wrap(opening, closing, this.valueOf()).valueOf();
}

Generic type variables

CustomOpeningextendsstring=Opening

A generic type variable constrained by the indicates the captured type of the supplied parameter and the type in the generic type via , by default generic type variable of the object.

CustomClosingextendsstring=Closing

A generic type variable constrained by the indicates the captured type of the supplied parameter and the type in the generic type via , by default generic type variable of the object.

Parameters

Return type

Wrapped<CustomOpening, Wrapped<Opening, Text, Closing>, CustomClosing>

Returns

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.wrap();

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

opening:

Optional opening chars of a generic type variable to wrap the of the instance.

closing:

Optional closing chars of a generic type variable to wrap the of the instance.

The return type is the generic type that takes generic type variables , and .

The return value is a wrapped by the and chars of the instance or the given and chars.

CustomOpening
primitive value
Wrapper
CustomOpening
CustomClosing
primitive value
Wrapper
CustomClosing
primitive value
opening
closing
Wrapper
opening
closing
primitive value
Wrapper
opening
closing
string
Wrapped
Wrapper
string
Wrapped
Wrapper
opening
closing
opening
return type
closing
return type
Wrapped
Opening
Closing
Opening
Closing
Opening
Text
Closing