Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.

Commit 871fa99

Browse files
committed
Split v4/5 and add websocket imports
1 parent 823a435 commit 871fa99

7 files changed

Lines changed: 559 additions & 458 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
export function convertSyntax(variable: string): string {
3+
if (!isJSString(variable)) return variable;
4+
return variable.replaceAll(/{{\s*(_\.)?([^}]+)\s*}}/g, '${[$2]}');
5+
}
6+
7+
export function isJSObject(obj: any) {
8+
return Object.prototype.toString.call(obj) === '[object Object]';
9+
}
10+
11+
export function isJSString(obj: any) {
12+
return Object.prototype.toString.call(obj) === '[object String]';
13+
}
14+
15+
export function convertId(id: string): string {
16+
if (id.startsWith('GENERATE_ID::')) {
17+
return id;
18+
}
19+
return `GENERATE_ID::${id}`;
20+
}
21+
22+
export function deleteUndefinedAttrs<T>(obj: T): T {
23+
if (Array.isArray(obj) && obj != null) {
24+
return obj.map(deleteUndefinedAttrs) as T;
25+
} else if (typeof obj === 'object' && obj != null) {
26+
return Object.fromEntries(
27+
Object.entries(obj)
28+
.filter(([, v]) => v !== undefined)
29+
.map(([k, v]) => [k, deleteUndefinedAttrs(v)]),
30+
) as T;
31+
} else {
32+
return obj;
33+
}
34+
}

0 commit comments

Comments
 (0)