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.isWrapper()
  • Generic type variables
  • Parameters
  • Return type
  • Returns
  • Example usage
  • Returns true
  • Return false
  • Confirms the wrong type

Was this helpful?

  1. Wrapper {}
  2. Methods
  3. Static

isWrapper()

Previousdefine()NextreplaceClosing()

Last updated 3 years ago

Was this helpful?

Wrapper.isWrapper()

The method checks if the of any type is an instance of the of any, or given , chars, and .

wrapper.class.ts
public static isWrapper<
  Opening extends string,
  Closing extends string,
  Text extends string = string
>(
  value: any,
  opening?: Opening,
  closing?: Closing,
  text?: Text
): value is Wrapper<Opening, Text, Closing> {
  return (
    typeof value === 'object' &&
    value instanceof this &&
    super.isWrap(value, opening, closing, text)
  );
}

Generic type variables

Openingextendsstring

Closingextendsstring

Textextendsstring=string

Parameters

value: any

opening?: Opening

closing?: Closing

text?: Text

Return type

value is Wrapper<Opening, Text, Closing>

Returns

Example usage

Returns true

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

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

// Returns true confirming the type Wrapper<string, string, string>
Wrapper.isWrapper(tagWrapper);

// Returns true confirming the type Wrapper<"[", string, string>
Wrapper.isWrapper(tagWrapper, '[');

// Returns true confirming the type Wrapper<"[", string, "]">
Wrapper.isWrapper(tagWrapper, '[', ']');

// Returns true confirming the type Wrapper<"[", "quote", "]">
Wrapper.isWrapper(tagWrapper, '[', ']', 'quote');

// Returns true confirming the type Wrapper<string, "quote", "]">
Wrapper.isWrapper(tagWrapper, undefined, ']', 'quote');

// Returns true confirming the type Wrapper<"[", "quote", string>
Wrapper.isWrapper(tagWrapper, '[', undefined, 'quote');

// Returns true confirming the type Wrapper<string, "quote", string>
Wrapper.isWrapper(tagWrapper, undefined, undefined, 'quote');

// Returns true confirming the type Wrapper<string, string, "]">
Wrapper.isWrapper(tagWrapper, undefined, ']');

// Returns true confirming the type Wrapper<"[", string, "]">
Wrapper.isWrapper<'[', ']'>(tagWrapper);

Return false

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

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

// Returns false denying the type Wrapper<"<", string, string>
Wrapper.isWrapper(tagWrapper, '<');

// Returns false denying the type Wrapper<"<", string, ">">
Wrapper.isWrapper(tagWrapper, '<', '>');

// Returns false denying the type Wrapper<"<", "quote", ">">
Wrapper.isWrapper(tagWrapper, '<', '>', 'quote');

// Returns false denying the type Wrapper<string, "quote", ">">
Wrapper.isWrapper(tagWrapper, undefined, '>', 'quote');

// Returns false denying the type Wrapper<"<", "quote", string>
Wrapper.isWrapper(tagWrapper, '<', undefined, 'quote');

// Returns false denying the type Wrapper<string, "no-quote", string>
Wrapper.isWrapper(tagWrapper, undefined, undefined, 'no-quote');

// Returns false denying the type Wrapper<string, string, ">">
Wrapper.isWrapper(tagWrapper, undefined, '>');

// Returns false denying the type Wrapper<"[", "", "]">
Wrapper.isWrapper<'[', ']'>(null as any);

Confirms the wrong type

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

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

// Returns true confirming the type Wrapper<"<", string, ">">
Wrapper.isWrapper<'<', '>'>(tagWrapper);

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

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

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

The value of any type to test against the instance of .

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 generic type variable to check if the given contains.

The return type is a that indicates the is the instance.

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

Wrapper
Wrapper
value
opening
closing
text
string
Wrapper
opening
return type
string
Wrapper
closing
return type
string
Wrapper
text
return type
Opening
value
Closing
value
Text
value
boolean
Wrapper
value
boolean
Wrapper
value
opening
closing
text