githubEdit

isAttribute()

Attribute.isAttribute()

The method checks whether the value of any type is the Wrap instance of any or given opening and closing chars.

attribute.class.ts
public static isAttribute<Name extends string, Value extends string>(
  value: any,
  name?: Name,
  val?: Value
): value is Attribute<Name, Value> {
  return typeof value === 'object' && value instanceof this
    ? (typeof name === 'string' ? value.name === name : true) &&
        (typeof val === 'string' ? value.value === val : true)
    : false;
}
Generic type variables

Name extends string

A generic type variable constrained by the stringarrow-up-right, by default of the value captured from the provided opening indicates the Opening type of the Wrap instance the return type.

Value extends string

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

Parameters

Name: type
Description

value: any

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

name?: Name

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

val?: Value

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

Returns

Return type

value is Attribute<Name, Value>

The return type is a boolean indicating the value parameter is an instance of Wrap that takes a generic type variable Opening Text and Closing.

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

Example usage

Last updated