refactor(domain): share AST property name reader

This commit is contained in:
morluto
2026-09-29 19:07:05 +08:00
parent dcb036292e
commit 4f4cc59873
3 changed files with 14 additions and 15 deletions
+2 -7
View File
@@ -2,6 +2,8 @@ import { createHash } from "node:crypto";
import * as t from "@babel/types";
import { propertyName } from "./javascriptAstValues.js";
/** Static CommonJS export names. */
export interface StaticExports {
readonly values: readonly string[];
@@ -121,13 +123,6 @@ const memberPath = (node: t.Node | null | undefined): string => {
return "";
};
const propertyName = (node: t.Node): string => {
if (t.isIdentifier(node)) return node.name;
if (t.isStringLiteral(node) || t.isNumericLiteral(node))
return String(node.value);
return "";
};
const stringValue = (node: t.Node | null | undefined): string | undefined =>
t.isStringLiteral(node) ? node.value : undefined;