build: trident-sync prepare

This commit is contained in:
xiaojunnuo
2023-01-29 13:44:19 +08:00
parent dcd1023a39
commit 07a45b4530
589 changed files with 36886 additions and 2 deletions
@@ -0,0 +1,33 @@
import _ from "lodash-es";
export default {
arrayToMap(array) {
if (!array) {
return {};
}
if (!_.isArray(array)) {
return array;
}
const map = {};
for (const item of array) {
if (item.key) {
map[item.key] = item;
}
}
return map;
},
mapToArray(map) {
if (!map) {
return [];
}
if (_.isArray(map)) {
return map;
}
const array: any = [];
for (const key in map) {
const item = map[key];
item.key = key;
array.push(item);
}
return array;
}
};