From ea2ebe26e1a551de1cd2562dd75c851dddddeaaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Thu, 7 Nov 2024 15:07:07 +0800 Subject: [PATCH] feat: isTaggedFunctionCallOf --- src/check.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/check.ts b/src/check.ts index 8641b16..1790e97 100644 --- a/src/check.ts +++ b/src/check.ts @@ -57,6 +57,24 @@ export function isCallOf( ) } +/** + * Checks if the given node is a TaggedTemplateExpression with the specified callee. + * + * @param node - The node to check. + * @param test - The callee to compare against. It can be a string, an array of strings, or a function that takes a string and returns a boolean. + * @returns True if the node is a TaggedTemplateExpression with the specified callee, false otherwise. + */ +export function isTaggedFunctionCallOf( + node: t.Node | null | undefined, + test: string | string[] | ((id: string) => boolean), +): node is t.TaggedTemplateExpression { + return ( + !!node && + node.type === 'TaggedTemplateExpression' && + isIdentifierOf(node.tag, test) + ) +} + /** * Checks if the given node is an Identifier with the specified name. * -- knotmirror 0.0.1