|
@@ -0,0 +1,20 @@
|
|
|
+import { HashMap } from "@kit.ArkTS";
|
|
|
+
|
|
|
+/**
|
|
|
+ * 常用方法,部分方法,在ets里面不能用
|
|
|
+ */
|
|
|
+export class ToolsHelperForTS {
|
|
|
+ // Map转为Record
|
|
|
+ static mapToRecord(myMap: HashMap<string, string>): Record<string, string> {
|
|
|
+ return Object.fromEntries(myMap.entries()) as Record<string, string>;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Record转为Map
|
|
|
+ static recordToMap(myRecord: Record<string, string>): HashMap<string, string> {
|
|
|
+ let myMap: HashMap<string, string> = new HashMap();
|
|
|
+ for (const key in myRecord) {
|
|
|
+ myMap.set(key, myRecord[key]);
|
|
|
+ }
|
|
|
+ return myMap;
|
|
|
+ }
|
|
|
+}
|