本文整理汇总了TypeScript中lodash.uniqBy函数的典型用法代码示例。如果您正苦于以下问题:TypeScript uniqBy函数的具体用法?TypeScript uniqBy怎么用?TypeScript uniqBy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uniqBy函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: if
.scan<Hero[]>((heroes: Hero[], action: Action) => {
const oldHeroes = heroes;
if (action instanceof EditHero) {
const editedHero = action.hero;
heroes = lodash.uniqBy([editedHero, ...heroes], 'id');
} else if (action instanceof AddHero) {
const newHero = action.hero;
heroes = lodash.uniqBy([newHero, ...heroes], 'id');
} else if (action instanceof DeleteHero) {
const deleteId = action.id;
heroes = lodash.reject(heroes, { id: deleteId });
}
logger('Store - heroReducer', oldHeroes, heroes);
return lodash.orderBy(heroes, ['id'], ['asc']);
}, initHeroes);
示例2: async
export const getSuggestions = async(job: Job, caretPosition: number) => {
const node = leafNodeAt(caretPosition, job.prompt.ast);
const suggestions = await node.suggestions({
environment: job.environment,
historicalPresentDirectoriesStack: job.session.historicalPresentDirectoriesStack,
aliases: job.session.aliases,
});
const applicableSuggestions = _.uniqBy(suggestions, suggestion => suggestion.value).filter(suggestion =>
suggestion.value.toLowerCase().startsWith(node.value.toLowerCase())
);
if (applicableSuggestions.length === 1) {
const suggestion = applicableSuggestions[0];
/**
* The suggestion would simply duplicate the prompt value without providing no
* additional information. Skipping it for clarity.
*/
if (node.value === suggestion.value && suggestion.description.length === 0 && suggestion.synopsis.length === 0) {
return [];
}
}
return applicableSuggestions.slice(0, suggestionsLimit);
};
示例3: filterItems
_.each(dimVendorService.vendors, (vendor: any) => {
const vendItems = filterItems(
vendor.allItems
.map((i) => i.item)
.filter(
(item) =>
item.bucket.sort === 'Armor' || item.type === 'Artifact' || item.type === 'Ghost'
)
);
vendorItems = vendorItems.concat(vendItems);
// Exclude felwinters if we have them
const felwinters = vendorItems.filter((i) => i.hash === 2672107540);
if (felwinters.length) {
vm.excludeditems.push(...felwinters);
vm.excludeditems = _.uniqBy(vm.excludeditems, (i) => i.id);
}
// Build a map of perks
_.each(vendItems, (item) => {
if (item.classType === 3) {
_.each(['warlock', 'titan', 'hunter'], (classType) => {
vendorPerks[classType][item.type] = filterPerks(
vendorPerks[classType][item.type],
item
);
});
} else {
vendorPerks[item.classTypeName][item.type] = filterPerks(
vendorPerks[item.classTypeName][item.type],
item
);
}
});
});
示例4: fetchOncoKbData
export async function fetchOncoKbData(uniqueSampleKeyToTumorType:{[uniqueSampleKey: string]: string},
annotatedGenes:{[entrezGeneId:number]:boolean}|Error,
mutationData:MobxPromise<Mutation[]>,
evidenceTypes?: string,
uncalledMutationData?:MobxPromise<Mutation[]>,
client: OncoKbAPI = oncokbClient)
{
const mutationDataResult = concatMutationData(mutationData, uncalledMutationData);
if (annotatedGenes instanceof Error) {
return new Error();
}
else if (mutationDataResult.length === 0) {
return ONCOKB_DEFAULT;
}
const mutationsToQuery = _.filter(mutationDataResult, m=>!!annotatedGenes[m.entrezGeneId]);
const queryVariants = _.uniqBy(_.map(mutationsToQuery, (mutation: Mutation) => {
return generateQueryVariant(mutation.gene.entrezGeneId,
cancerTypeForOncoKb(mutation.uniqueSampleKey, uniqueSampleKeyToTumorType),
mutation.proteinChange,
mutation.mutationType,
mutation.proteinPosStart,
mutation.proteinPosEnd);
}), "id");
return queryOncoKbData(queryVariants, uniqueSampleKeyToTumorType, client, evidenceTypes);
}
示例5: fetchOncoKbDataForMutations
export async function fetchOncoKbDataForMutations(annotatedGenes:{[entrezGeneId:number]:boolean}|Error,
data:OncoprinterGeneticTrackDatum_Data[],
client: OncoKbAPI = oncokbClient)
{
if (annotatedGenes instanceof Error) {
return new Error();
}
const mutationsToQuery = _.chain(data).filter(m=>!!annotatedGenes[m.entrezGeneId])
.filter(d=>(d.proteinPosStart !== undefined && d.proteinPosEnd !== undefined))
.value();
if (mutationsToQuery.length === 0) {
return ONCOKB_DEFAULT;
}
const queryVariants = _.uniqBy(_.map(mutationsToQuery, (mutation) => {
return generateQueryVariant(mutation.entrezGeneId,
null,
mutation.proteinChange,
mutation.mutationType,
mutation.proteinPosStart,
mutation.proteinPosEnd);
}), "id");
return queryOncoKbData(queryVariants, {}, client, "ONCOGENIC");
}
示例6: ngOnInit
async ngOnInit() {
this.showAtHome = this.homeIntegrationsProvider.shouldShowInHome(
'giftcards'
);
const purchasedCards = await this.giftCardProvider.getPurchasedBrands();
this.purchasedBrands = _.uniqBy(purchasedCards, ([cards]) => cards.brand);
}
示例7: addFieldFilter
addFieldFilter(filter) {
let field = this.fields[filter.field] || {filters: {}};
field.filters[filter.key] = {
value: filter.name,
onRemove: (filter.events !== undefined) && filter.events.remove
};
let label = (filter.fieldLabel ? filter.fieldLabel : filter.field)
+ " = '" + filter.name + "'";
let query = '(' + filter.field + ":" + _.map(_.keys(field.filters)).join(' OR ') + ')';
this.filters.push({
source: filter.widget,
key: filter.field + '_' + filter.key,
label: label
});
this.filters = _.uniqBy(this.filters, 'key');
field.query = query;
this.fields[filter.field] = field;
this.lastSource = filter.widget;
this.createAndSendQuery(filter.silent);
}
示例8: findFirst
export const testAnalyserItem = (appTrackItems, analyseSetting) => {
if (!appTrackItems) {
console.error('appTrackItems not loaded');
return;
}
const testItems: any = [];
appTrackItems.forEach(item => {
const testItem = { ...item };
let str = testItem.title;
testItem.findRe = findFirst(str, analyseSetting.findRe);
testItem.takeGroup = findFirst(str, analyseSetting.takeGroup) || testItem.findRe;
testItem.takeTitle = findFirst(str, analyseSetting.takeTitle) || testItem.title;
if (testItem.findRe) {
testItems.push(testItem);
}
});
const analyserTestItems = _.uniqBy(testItems, 'title');
return analyserTestItems;
};
示例9: flatten
return flatten(arr).map((endpointQuery: EndpointQuery) => {
return {
title: endpointQuery.endpoint.replace('/', ' '),
fields: endpointQuery.mapping ?
uniqBy(Object.keys(endpointQuery.mapping), path => path.split('.')[0]).map(name => name.replace(/_/g, ' '))
: ['NONE']
};
});