當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。