Static methods

Tag.

Public

isTag()

The static method checks whether the provided value of any type is an instance of Tag.

public static isTag<Name extends string, Chars extends string = string>(
  value: any,
  name?: Name,
  chars?: Chars
): value is Tag<Name, Chars> {
  return isInstance(value, Tag)
    ? isDefined(name) || isDefined(chars)
      ? isDefined(name) && isDefined(chars)
        ? value.wrap.value === chars && value.name === name
        : isDefined(name)
        ? value.name === name
        : value.wrap.value === chars
      : true
    : false;
}

Generic type variables

Name / Description

Name extends string

​A generic type variable constrained by a string by default of the value captured from the provided name indicates the text type of Tag via the return type.

Chars extends string

​A generic type variable constrained by a string by default of the value captured from the provided chars parameter indicates the chars type of Tag via the return type.

Parameters

Name: typeDescription

value: any

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

name?: Name

An optional tag name of a generic type variable Name.

chars?: Chars

An optional wrap of a generic type variable Chars.

Returns

Return type

value is Tag<Name, Chars>

The return type is a boolean indicating the value parameter is an instance of Tag that takes a generic type variable Name the tag name and Chars the wrap.

The return value is a boolean indicating whether the value is the Tag instance of any or given name, or of any or given wrap.

Example usage

// Example usage.
import { Tag } from '@angular-package/text';

// Define the tag.
const quote = new Tag(`quote`);

// Returns `true`
Tag.isTag(quote, `quote`);

// Returns `true`
Tag.isTag(quote, `quote`, '[]');

// Returns `false`
Tag.isTag(quote, `quote`, '()');

Last updated