Static methods
Tag.
Public
isTag()
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
Parameters
Name: type
Description
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
Was this helpful?