本文整理汇总了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
};
}
示例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()]);
};
示例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
};
}
示例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;
}
}
}
示例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;
})();
示例6: function
function(tulos) {
self.arviointiasteikot = _.indexBy(tulos, "id");
$rootScope.$broadcast("arviointiasteikot");
},