mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-29 18:04:09 +01:00
refactor: Add type annotations and optimize redundant set loop
This commit is contained in:
@@ -36,7 +36,8 @@ let classCounter = 0;
|
||||
let namespaces = new Map<string, NamespaceNode>();
|
||||
let namespaceCounter = 0;
|
||||
|
||||
let functions: any[] = [];
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
||||
let functions: Function[] = [];
|
||||
|
||||
const sanitizeText = (txt: string) => common.sanitizeText(txt, getConfig());
|
||||
|
||||
@@ -125,12 +126,12 @@ export const lookUpDomId = function (_id: string): string {
|
||||
|
||||
export const clear = function () {
|
||||
relations = [];
|
||||
classes = new Map();
|
||||
classes = new Map<string, ClassNode>();
|
||||
notes = new Map<string, ClassNote>();
|
||||
interfaces = [];
|
||||
functions = [];
|
||||
functions.push(setupToolTips);
|
||||
namespaces = new Map();
|
||||
namespaces = new Map<string, NamespaceNode>();
|
||||
namespaceCounter = 0;
|
||||
direction = 'TB';
|
||||
commonClear();
|
||||
@@ -602,9 +603,7 @@ export const getData = () => {
|
||||
const edges: Edge[] = [];
|
||||
const config = getConfig();
|
||||
|
||||
for (const namespaceKey of namespaces.keys()) {
|
||||
const namespace = namespaces.get(namespaceKey);
|
||||
if (namespace) {
|
||||
for (const namespace of namespaces.values()) {
|
||||
const node: Node = {
|
||||
id: namespace.id,
|
||||
label: namespace.id,
|
||||
@@ -617,17 +616,13 @@ export const getData = () => {
|
||||
};
|
||||
nodes.push(node);
|
||||
}
|
||||
}
|
||||
|
||||
for (const classKey of classes.keys()) {
|
||||
const classNode = classes.get(classKey);
|
||||
if (classNode) {
|
||||
for (const classNode of classes.values()) {
|
||||
const node = classNode as unknown as Node;
|
||||
node.parentId = classNode.parent;
|
||||
node.look = config.look;
|
||||
nodes.push(node);
|
||||
}
|
||||
}
|
||||
|
||||
for (const note of notes.values()) {
|
||||
const noteNode: Node = {
|
||||
|
||||
Reference in New Issue
Block a user