Comparing version 0.0.35 to 0.0.36
@@ -5,3 +5,4 @@ export declare enum NodeType { | ||
ResponseAsync = "ResponseAsync", | ||
AsyncReturn = "AsyncReturn" | ||
AsyncReturn = "AsyncReturn", | ||
Boolean = "Boolean" | ||
} | ||
@@ -8,0 +9,0 @@ export declare class GraphNode { |
@@ -10,2 +10,3 @@ "use strict"; | ||
NodeType["AsyncReturn"] = "AsyncReturn"; | ||
NodeType["Boolean"] = "Boolean"; | ||
})(NodeType || (exports.NodeType = NodeType = {})); | ||
@@ -12,0 +13,0 @@ class GraphNode { |
{ | ||
"name": "ts2uml", | ||
"version": "0.0.35", | ||
"version": "0.0.36", | ||
"description": "typescript workflow to uml sequence", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,21 +18,20 @@ "use strict"; | ||
let currentMethodName = null; | ||
for (let i = targetLineNumber; i > lines.length; i--) { | ||
// Ensure targetLineNumber is within bounds | ||
if (targetLineNumber < 0 || targetLineNumber > lines.length) { | ||
throw new Error("targetLineNumber is out of bounds"); | ||
} | ||
for (let i = targetLineNumber - 1; i >= 0; i--) { | ||
const line = lines[i]; | ||
const lineNumber = i + 1; | ||
// Match class declaration | ||
const classMatch = line.match(/class\s+(\w+)/); | ||
// Match class declaration, considering possible keywords like 'export' | ||
const classMatch = line.match(/(?:export\s+)?(?:abstract\s+)?class\s+(\w+)/); | ||
if (classMatch) { | ||
currentClassName = classMatch[1]; | ||
break; | ||
} | ||
// Match method declaration (simplified, assuming methods are not nested) | ||
const methodMatch = line.match(/(?:async\s+)?(?:static\s+)?\w+\s+(\w+)\(/); | ||
if (methodMatch) { | ||
currentMethodName = methodMatch[1]; | ||
const methodOrFunctionMatch = line.match(/(?:async\s+)?(?:function\s+)?(?:public\s+|private\s+|protected\s+|static\s+)?\*?\s*(\w+)\s*(?:\((?:[^)]*)\))\s*(?:=>)?{/); | ||
if (!currentMethodName && methodOrFunctionMatch) { | ||
currentMethodName = methodOrFunctionMatch[1]; | ||
} | ||
// Check if the target line number is reached | ||
if (currentClassName) { | ||
return { className: currentClassName, method: currentMethodName }; | ||
} | ||
} | ||
// Return null if no class or method is found at the given line number | ||
// Return after processing all lines or reaching the target line | ||
return { className: currentClassName, method: currentMethodName }; | ||
@@ -39,0 +38,0 @@ } |
@@ -122,6 +122,11 @@ "use strict"; | ||
}); | ||
const newNode = new model_1.GraphNode(prevClassName, prevMethod, className, method, result && Object.keys(result).length ? JSON.stringify(result) : "", new Date().getTime() - startTime.getTime(), model_1.NodeType.AsyncReturn); | ||
nodes.push(newNode); | ||
model_1._graphs.graphs[model_1._graphs._getRequestId()] = nodes; | ||
} | ||
const newNode = new model_1.GraphNode(prevClassName, prevMethod, className, method, result && Object.keys(result).length ? JSON.stringify(result) : "", new Date().getTime() - startTime.getTime(), result instanceof Promise ? model_1.NodeType.AsyncReturn : model_1.NodeType.Response); | ||
nodes.push(newNode); | ||
model_1._graphs.graphs[model_1._graphs._getRequestId()] = nodes; | ||
else { | ||
const newNode = new model_1.GraphNode(prevClassName, prevMethod, className, method, result && Object.keys(result).length ? JSON.stringify(result) : result, new Date().getTime() - startTime.getTime(), result instanceof Boolean ? model_1.NodeType.Boolean : model_1.NodeType.Response); | ||
nodes.push(newNode); | ||
model_1._graphs.graphs[model_1._graphs._getRequestId()] = nodes; | ||
} | ||
} | ||
@@ -128,0 +133,0 @@ function _clear() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49037
36
1066