-
Notifications
You must be signed in to change notification settings - Fork 0
tagged
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
function isTagged<O = {}, T extends string = string>(it: O): it is O & {
readonly [Symbol.toStringTag]: NormalizeTag<T>;
};Checks if a given value has a Symbol.toStringTag property, and optionally
checks if the value of that property matches the given
tag.
| Name | Info |
|---|---|
it |
The value to check. |
tag |
The value to check against. |
true if the value has a Symbol.toStringTag property that matches the given
tag (if provided), otherwise false.
Objects
function normalizeTag<T extends string>(tag: T): NormalizeTag<T>;Normalizes a given toStringTag value, removing any leading and trailing
whitespace and any leading [object and trailing ], if present.
function normalizeTag(tag: string): string;function normalizeTag(tag: string): string;export type NormalizeTag<T extends string> = Trim<
T extends `[object ${infer U}]` ? U : T
>;-
Textendsstring