zoukankan      html  css  js  c++  java
  • xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

    change object keys & UpperCase & LowerCase

    .toLocaleUpperCase(); && .toLocaleLowerCase();

    
    "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,
    };
    
    
    
    

    OK

  • 相关阅读:
    动态添加删除控件
    文件下载源码
    poj 1300 欧拉回路、通路 解题报告
    hdu 1232 并查集 或者 深搜
    hdu 2546 01背包问题
    强连通图的判断 hdu 1269
    hdu 2159 二维费用背包问题
    Hdu 3336 kmp+dp解题报告
    hdu 3639 强连通练习使用
    hdu 1712 分组背包问题
  • 原文地址:https://www.cnblogs.com/xgqfrms/p/10168377.html
Copyright © 2011-2022 走看看