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
  • Wrap.isWrap()
  • Generic type variables
  • Parameters
  • Return type
  • Returns
  • Example usage

Was this helpful?

  1. Wrap {}
  2. Methods
  3. Static

isWrap()

PrevioushasOpening()NextInstance

Last updated 3 years ago

Was this helpful?

Wrap.isWrap()

The method checks whether the of any type is the instance of any or given and chars.

wrap.class.ts
public static isWrap<
  Opening extends string = string,
  Closing extends string = string,
  Text extends string = ``
>(
  value: any,
  opening?: Opening,
  closing?: Closing,
  text?: Text
): value is Wrap<Opening, Text, Closing> {
  return typeof value === 'object' && value instanceof this
    ? (typeof opening === 'string' ? opening === value.opening : true) &&
        (typeof closing === 'string' ? closing === value.closing : true) &&
        (typeof text === 'string' ? text === value.text : true)
    : false;
}

Generic type variables

Openingextendsstring=string

Closingextendsstring=string

Textextendsstring=``

Parameters

value: any

opening?: Opening

closing?: Closing

text?: Text

Return type

value is Wrap<Opening, Text, Closing>

Returns

Example usage

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

const tagWrap = new Wrap(`[`, `]`, 'quote');

// Returns true confirming the type Wrap<"[", "", "]">
Wrap.isWrap(tagWrap);

// Returns true, confirming the type Wrap<"[", "", "]">
Wrap.isWrap(tagWrap, '[', ']');

// Returns true, confirming the type Wrap<"[", "quote", "]">
Wrap.isWrap(tagWrap, '[', ']', 'quote');

// Returns true, confirming the type Wrap<"[", "", "]">
Wrap.isWrap<'[', ']'>(tagWrap, '[', ']');

// Returns false, denying the type Wrap<"[", "span", "]">
Wrap.isWrap(tagWrap, '[', ']', 'span');

// Returns false denying the value is Wrap<"(", "", ")">
Wrap.isWrap(tagWrap, '(', ')');

// Returns false denying the value is Wrap<"(", "", ")">
Wrap.isWrap<'[', ']'>(null as any);

// Returns false denying the value is Wrap<"[", "", "]">
Wrap.isWrap(null as any, '[', ']');

A generic type variable constrained by the , by default of the value captured from the provided indicates the Opening type of the instance the .

A generic type variable constrained by the , by default of the value captured from the provided indicates the Closing type of the instance via .

A generic type variable constrained by the , by default of the value captured from the provided indicates the Text type of the instance via .

The value of type to test against the instance of any or given and .

Optional opening chars of a generic type variable to check if the given contains.

Optional closing chars of a generic type variable to check if the given contains.

An optional text of a generic type variable to check if the given contains.

The return type is a indicating the parameter is an instance of that takes a generic type variable and .

The return value is a type indicating whether the is an instance of of any, or the given , , and .

Wrap
value
opening
closing
string
Wrap
opening
return type
string
Wrap
closing
return type
string
Wrap
text
return type
any
Wrap
opening
closing
Opening
value
Closing
value
Text
value
boolean
Wrap
value
Opening
Text
Closing
boolean
Wrap
value
opening
closing
text