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

Was this helpful?

Edit on GitHub
  1. Wrapper {}
  2. Methods

static isWrapper()

Previousstatic define()Nextstatic replaceClosing()

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

Parameters

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);

Openingextends

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 .

Closingextends

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 .

Textextends=

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 .

value:

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

opening?:

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

closing?:

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

text?:

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 .

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