githubEdit

static isWrapper()

Wrapper.isWrapper()

The method checks if the value of any type is an instance of the Wrapper of any, or given opening, closing chars, and text.

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

Openingextendsstringarrow-up-right

A generic type variable constrained by the stringarrow-up-right, by default of the value captured from the provided opening indicates the type of the opening in the Wrapper via return type.

Closingextendsstringarrow-up-right

A generic type variable constrained by the stringarrow-up-right, by default of the value captured from the provided closing indicates the type of the closing in the Wrapper via return type.

A generic type variable constrained by the stringarrow-up-right, by default of the value captured from the provided text indicates the type of the text in the Wrapper via return type.

Parameters

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

opening?:Opening

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

closing?:Closing

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

text?:Text

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

Return type

value is Wrapper<Opening, Text, Closing>

The return type is a booleanarrow-up-right that indicates the value is the Wrapper instance.

Returns

The return value is a booleanarrow-up-right type indicating whether the value is an instance of Wrapper of any, or the given opening, closing chars, and text.

Example usage

Returns true

Return false

Confirms the wrong type

Last updated