change object keys & UpperCase & LowerCase
"use strict";
/**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
* @created 2018.12.24
* @modified 2018.12.24
*
* @description Utils & ChangeObjectKeys
* @augments
* @example ChangeObjectKeys(tab_datas, tab_keys);
* @example shapeArrayTabs(new_outputs, outputs);
*
*/
const shapeArrayTabs = (new_outputs = [], outputs = []) => {
let result = [];
new_outputs.forEach(
(obj, i) => {
let {
tab_keys,
} = obj;
let {
tab_name,
tab_datas,
} = outputs[i];
let temp = {
tab_name,
};
temp["tab_datas"] = ChangeObjectKeys(tab_datas, tab_keys);
result.push(temp);
}
);
return result;
};
const ChangeObjectKeys = (tab_datas = [], tab_keys = []) => {
let result = [];
tab_datas.forEach(
(obj, i) => {
let {
key,
} = obj;
let keys = Object.keys(obj);
let temp = {
key,
};
tab_keys.forEach(
(item, i) => {
let UpperKey = item.toLocaleUpperCase();
if (keys.includes(UpperKey)) {
temp[item] = obj[UpperKey];
}
}
);
result.push(temp);
}
);
return result;
};
const ResultUtils = {
shapeArrayTabs,
ChangeObjectKeys,
};
export default ResultUtils;
export {
shapeArrayTabs,
ChangeObjectKeys,
};