MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / formatPath

Function formatPath

frontend/util/ijson.ts:11–30  ·  view source on GitHub ↗
(path: PathType)

Source from the content-addressed store, hash-verified

9const simplePathStrRe = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
10
11function formatPath(path: PathType): string {
12 if (path.length == 0) {
13 return "$";
14 }
15 let pathStr = "$";
16 for (const pathPart of path) {
17 if (typeof pathPart === "string") {
18 if (simplePathStrRe.test(pathPart)) {
19 pathStr += "." + pathPart;
20 } else {
21 pathStr += "[" + JSON.stringify(pathPart) + "]";
22 }
23 } else if (typeof pathPart === "number") {
24 pathStr += "[" + pathPart + "]";
25 } else {
26 pathStr += ".*";
27 }
28 }
29 return pathStr;
30}
31
32function isArray(obj: any): boolean {
33 return obj != null && Array.isArray(obj);

Callers 2

setPathFunction · 0.85
applyCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected