当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.indexBy函数代码示例

本文整理汇总了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;未经允许,请勿转载。