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

TypeScript lodash.indexBy函数代码示例

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

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



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

示例1: getWaterfall

export function getWaterfall(
  { trace, errorsPerTransaction }: TraceAPIResponse,
  entryTransactionId?: Transaction['transaction']['id']
): IWaterfall {
  if (isEmpty(trace) || !entryTransactionId) {
    return {
      services: [],
      duration: 0,
      orderedItems: [],
      itemsById: {},
      getTransactionById: () => undefined,
      errorCountByTransactionId: errorsPerTransaction,
      serviceColors: {}
    };
  }

  const waterfallItems = trace.map(traceItem => {
    const docType = traceItem.processor.event;
    switch (docType) {
      case 'span':
        return getSpanItem(traceItem as Span);
      case 'transaction':
        return getTransactionItem(
          traceItem as Transaction,
          errorsPerTransaction
        );
    }
  });

  const childrenByParentId = groupBy(waterfallItems, item =>
    item.parentId ? item.parentId : 'root'
  );
  const entryTransactionItem = waterfallItems.find(
    waterfallItem =>
      waterfallItem.docType === 'transaction' &&
      waterfallItem.id === entryTransactionId
  );
  const itemsById: IWaterfallIndex = indexBy(waterfallItems, 'id');
  const orderedItems = entryTransactionItem
    ? getOrderedWaterfallItems(childrenByParentId, entryTransactionItem)
    : [];
  const traceRoot = getTraceRoot(childrenByParentId);
  const duration = getDuration(orderedItems);
  const traceRootDuration = traceRoot && traceRoot.transaction.duration.us;
  const services = getServices(orderedItems);
  const getTransactionById = createGetTransactionById(itemsById);
  const serviceColors = getServiceColors(services);

  return {
    traceRoot,
    traceRootDuration,
    duration,
    services,
    orderedItems,
    itemsById,
    getTransactionById,
    errorCountByTransactionId: errorsPerTransaction,
    serviceColors
  };
}
开发者ID:njd5475,项目名称:kibana,代码行数:60,代码来源:waterfall_helpers.ts


示例2: indexBy

export const sortKeysByConfig: KeySorter = (object, currentKey) => {
  const indexedPropertyConfig = indexBy(TAB_CONFIG, 'key');
  const presorted = get(
    indexedPropertyConfig,
    `${currentKey}.presortedKeys`,
    []
  );
  return uniq([...presorted, ...Object.keys(object).sort()]);
};
开发者ID:njd5475,项目名称:kibana,代码行数:9,代码来源:tabConfig.ts


示例3: getWaterfall

export function getWaterfall(
  hits: Array<Span | Transaction>,
  entryTransaction: Transaction
): IWaterfall {
  if (isEmpty(hits)) {
    return {
      services: [],
      duration: 0,
      items: [],
      itemsById: {},
      getTransactionById: () => undefined,
      serviceColors: {}
    };
  }

  const filteredHits = hits
    .filter(hit => {
      const docType = hit.processor.event;
      return ['span', 'transaction'].includes(docType);
    })
    .map(hit => {
      const docType = hit.processor.event;
      switch (docType) {
        case 'span':
          return getSpanItem(hit as Span);
        case 'transaction':
          return getTransactionItem(hit as Transaction);
        default:
          throw new Error(`Unknown type ${docType}`);
      }
    });

  const childrenByParentId = groupBy(filteredHits, hit =>
    hit.parentId ? hit.parentId : 'root'
  );
  const entryTransactionItem = getTransactionItem(entryTransaction);
  const itemsById: IWaterfallIndex = indexBy(filteredHits, 'id');
  const items = getWaterfallItems(childrenByParentId, entryTransactionItem);
  const traceRoot = getTraceRoot(childrenByParentId);
  const duration = getDuration(items);
  const traceRootDuration = traceRoot && traceRoot.transaction.duration.us;
  const services = getServices(items);
  const getTransactionById = createGetTransactionById(itemsById);
  const serviceColors = getServiceColors(services);

  return {
    traceRoot,
    traceRootDuration,
    duration,
    services,
    items,
    itemsById,
    getTransactionById,
    serviceColors
  };
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:56,代码来源:waterfall_helpers.ts


示例4: readNode

export function readNode(el:libxml.Element, defs:Array<cbi.ElementDef>, elementWrapper: cbi.ElementWrapper){

  if(!el) return;

  const tags = _.indexBy(defs,'tag');

  for(const childNode of el.childNodes()){

    const def = tags[ childNode.name()];

    if ( def === undefined ) continue;

    if(def.children){
      readNode(childNode, def.children, elementWrapper);
      continue;
    }

    var getValue;

    if (def.type && types[def.type] !== undefined){
      getValue = types[def.type].get(childNode, elementWrapper);
    }
    // se ho definito una funzione get la eseguo per ottenere il valore
    else if (typeof def.get === 'function'){
      getValue = def.get(childNode, elementWrapper);
    }
    // altrimenti leggo il contenuto
    else{
      getValue = childNode.text();
    }

    // se il contenuto è un array faccio il push
    if(Array.isArray(elementWrapper[def.prop])){
      elementWrapper[def.prop].push(getValue);
    }
    // altrimenti sovrascrivo
    else{
      elementWrapper[def.prop] = getValue;
    }
  }
}
开发者ID:digideskio,项目名称:cbi,代码行数:41,代码来源:xml_utils.ts


示例5: lataaKvliite

 (async function lataaKvliite() {
     const arviointiasteikotP = Arviointiasteikot.list().$promise;
     const kvliite = await Perusteet.kvliite({ perusteId: $scope.peruste.id }).$promise;
     const arviointiasteikot = await arviointiasteikotP;
     kvliite.tasot = _.filter(kvliite.tasot, taso => (taso as any).nimi);
     $scope.arviointiasteikot = arviointiasteikot;
     $scope.arviointiasteikotMap = _.indexBy(arviointiasteikot, "id");
     // EP-1315
     const arviointiasteikko = _.find($scope.arviointiasteikotMap, (aa: any) => {
         return aa.osaamistasot.length === 1;
     });
     if (arviointiasteikko) {
         arviointiasteikko.osaamistasot[0].otsikko = {};
         _.each(Kieli.SISALTOKIELET, kieli => {
             arviointiasteikko.osaamistasot[0].otsikko[kieli] = Kaanna.kaanna("kvliiteen-yksiportainen-arviointiasteikko", kieli);
         });
     }
     $scope.kvliite = kvliite;
     $scope.kvliitePeriytynyt = !kvliite || kvliite.periytynyt;
     $scope.peruste.kvliite = kvliite;
     $scope.editablePeruste.kvliite = kvliite;
     $scope.useampiSuoritustapa = _.size(kvliite.muodostumisenKuvaus) > 1;
 })();
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:23,代码来源:perusteenTiedot.ts


示例6: function

 function(tulos) {
     self.arviointiasteikot = _.indexBy(tulos, "id");
     $rootScope.$broadcast("arviointiasteikot");
 },
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:4,代码来源:yleinenData.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.indexOf函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.includes函数代码示例发布时间: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