• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript lodash.mapKeys函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中lodash.mapKeys函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mapKeys函数的具体用法?TypeScript mapKeys怎么用?TypeScript mapKeys使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mapKeys函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: dumpToCSV

 public dumpToCSV(resultFile: string) {
   const newResult = _.mapKeys(this.result as _.Dictionary<any>, (v, k) => {
     if (k !== 'repoName') {
       return `${requestTypeMapping.get(this.requestType)}_${k}`;
     } else {
       return 'repoName';
     }
   });
   if (!fs.existsSync(resultFile)) {
     console.log(papa.unparse([newResult]));
     fs.writeFileSync(resultFile, papa.unparse([newResult]));
   } else {
     const file = fs.createReadStream(resultFile);
     papa.parse(file, {
       header: true,
       complete: parsedResult => {
         const originResults = parsedResult.data;
         const index = originResults.findIndex(originResult => {
           return originResult.repoName === newResult.repoName;
         });
         if (index === -1) {
           originResults.push(newResult);
         } else {
           originResults[index] = { ...originResults[index], ...newResult };
         }
         fs.writeFileSync(resultFile, papa.unparse(originResults));
       },
     });
   }
 }
开发者ID:elastic,项目名称:kibana,代码行数:30,代码来源:lsp_test_runner.ts


示例2: buildSorter

export function buildSorter(options: any, index?: number, bindVarsMap?: any): any {
  if (_.isNil(options.sort) || _.isEmpty(options.sort)) {
    return '';
  }

  if (!index) {
    index = 0;
  }
  if (!bindVarsMap) {
    bindVarsMap = {};
  }

  const sort = _.mapKeys(options.sort, (value, key) => {
    return autoCastKey(key);
  });
  let sortKeysOrder = '';
  let i = 1;
  let objLength = Object.keys(sort).length;
  for (let key in sort) {
    if (objLength == i) {
      // Do not append ',' for the last element
      sortKeysOrder = `${sortKeysOrder} ${key} ${sort[key]} `;
    } else {
      sortKeysOrder = `${sortKeysOrder} ${key} ${sort[key]},`;
    }
    i += 1;
  }
  return 'SORT ' + sortKeysOrder;
}
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:29,代码来源:common.ts


示例3: payments

export function payments(state: PaymentsState = initialState, {type, payload}: Action): PaymentsState {
  switch (type) {

    case PatientActions.REMOVE_SUCCESS: {
      const data = _.omitBy(state.data, p => p.patient_id == payload) as PaymentData;
      const ids = _.values(data).map(data => data['id']);
      return { ...state, ids, data };
    }

    case PaymentsActions.EDIT_SUCCESS: {
      return { ...state, data: { ...state.data, [payload.id]: payload } };
    }

    case PaymentsActions.CREATE_SUCCESS: {
      const data = { ...state.data, [payload.id]: payload };
      const ids = [payload.id, ...state.ids];
      return { selected: payload.id, status: true, ids , data };
    }

    case PaymentsActions.REMOVE_SUCCESS: {
      const ids = state.ids.filter(ids => ids !== payload.id);
      const data = _.omit(state.data, payload.id) as PaymentData;
      return { ...state, ids, data };
    }

    case PaymentsActions.INIT_SUCCESS: {
      const ids = payload.map(data => data.id);
      const data = _.mapKeys(payload, 'id') as PaymentData;

      return { ...state, status: false, ids, data };
    }

    default: return state;
  }
};
开发者ID:jogboms,项目名称:ClinicRegistry,代码行数:35,代码来源:payments.ts


示例4: diary

export function diary(state: DiaryState = initialState, {type, payload}: Action): DiaryState {
  switch (type) {
    case DiaryActions.SELECT: {
      const date = payload.date as Date;
      const y = date.getFullYear();
      const m = date.getMonth()+1;
      const d = date.getDate();
      return { ...state, date, selected: 'diary_'+d+'_'+m+'_'+y };
    }

    case DiaryActions.CREATE_SUCCESS: {
      const data = { ...state.data, [payload.id]: payload };
      const ids = [payload.id, ...state.ids];
      return { ...state, date: payload.date, selected: payload.id, status: true, ids , data };
    }

    case DiaryActions.INIT_SUCCESS: {
      const ids = payload.map(data => data.id);
      const data = _.mapKeys(payload, 'id') as DiaryData;

      return { ...state, status: false, ids, data };
    }

    default: return state;
  }
};
开发者ID:jogboms,项目名称:ClinicRegistry,代码行数:26,代码来源:diary.ts


示例5: store

export function store(state: StoreState = initialState, {type, payload}: Action): StoreState {
  switch (type) {
    case StoreActions.SELECT: {
      return { ...state, selected: payload.id };
    }

    case StoreActions.REMOVE_SUCCESS: {
      const ids = state.ids.filter(ids => ids !== payload.id);
      const data = _.omit(state.data, payload.id);
      return Object.assign({}, state, { ids, data });
    }

    case StoreActions.CREATE_SUCCESS: {
      const data = { ...state.data, [payload.id]: payload };
      const ids = [payload.id, ...state.ids];
      return { ...state, selected: payload.id, ids , data };
    }

    case StoreActions.INIT_SUCCESS: {
      const ids = payload.map(data => data.id);
      const data = _.mapKeys(payload, 'id') as StoreData;

      return { ...state, ids, data };
    }

    default: return state;
  }
};
开发者ID:jogboms,项目名称:ClinicRegistry,代码行数:28,代码来源:store.ts


示例6: patients

export function patients(state: PatientsState = initialState, {type, payload}: Action): PatientsState {
  switch (type) {
    case PatientActions.FETCH: {
      return Object.assign({}, state, { selected: payload });
    }

    case PatientActions.CREATE_SUCCESS: {
      const data = update_data(state.data, payload.id, { type, payload });
      const ids = [payload.id, ...state.ids];
      return Object.assign({}, { selected: payload.id, status: true, ids , data });
    }

    case PatientActions.EDIT_SUCCESS: {
      const data = update_data(state.data, payload.id, { type, payload });
      return Object.assign({}, state, { data });
    }

    case PatientActions.REMOVE_SUCCESS: {
      const ids = state.ids.filter(ids => ids !== payload);
      const data = _.omit(state.data, payload);
      return Object.assign({}, state, { ids, data });
    }

    case PatientsActions.INIT_SUCCESS: {
      const ids = payload.map(data => data.id);
      const data = _.mapKeys(payload, 'id') as PatientData;

      return Object.assign({}, state, { status: false, ids, data });
    }

    default: return state;
  }
};
开发者ID:jogboms,项目名称:ClinicRegistry,代码行数:33,代码来源:patients.ts


示例7: convertProps

function convertProps(attributes: xmlParser.Attributes): string {
  let props;
  props = _.mapKeys(attributes, (value: string, key: string) => _.camelCase(key));
  if (_.isEmpty(props)) {
    return "undefined";
  }
  return stringify(props);
}
开发者ID:barbuza,项目名称:react-icon-loader,代码行数:8,代码来源:utils.ts


示例8:

 return JSON.parse(JSON.stringify(model), (key, value) => {
   return _.isObject(value) && !_.isArray(value)
     ? _.mapKeys(value, (v, k: string) => {
         return k.replace(/{{[^{}]+}}/g, (token: string) => {
           return model[token.replace(/[{}]+/g, '')];
         });
       })
     : value;
 });
开发者ID:gingerwizard,项目名称:kibana,代码行数:9,代码来源:tags.ts


示例9: function

  return _.transform(obj, function (result, value, key) {
    if (_.isObject(value) && !_.isArray(value)) {
      const flatMap = _.mapKeys(flattenObject(value), (_mvalue, mkey) => {
        return `${key}.${mkey}`;
      });
      _.assign(result, flatMap);
    } else {
      result[key] = value;
    }

    return result;
  }, {});
开发者ID:qwb0920,项目名称:ext-ionic,代码行数:12,代码来源:util.ts


示例10:

  $("*").each((idx, element) => {
    const attrs = element.attribs;

    const patchedAttrs = _.mapKeys<any>(
      attrs,
      (value, key) => (attrsNeedToConvert[key] ? attrsNeedToConvert[key] : key),
    );

    _.assign(element, {
      attribs: patchedAttrs,
    });
  });
开发者ID:morlay,项目名称:simplify-svg,代码行数:12,代码来源:convertToReactJSX.ts



注:本文中的lodash.mapKeys函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.mapValues函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.map函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap