本文整理汇总了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);
开发者ID:ovrmrw,项目名称:ng2-heroes-editor,代码行数:15,代码来源:store.ts
示例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);
};
开发者ID:LeiZeng,项目名称:black-screen,代码行数:26,代码来源:Autocompletion.ts
示例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
);
}
});
});
开发者ID:w1cked,项目名称:DIM,代码行数:35,代码来源:loadout-builder.component.ts
示例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);
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:27,代码来源:StoreUtils.ts
示例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");
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:26,代码来源:OncoprinterUtils.ts
示例6: ngOnInit
async ngOnInit() {
this.showAtHome = this.homeIntegrationsProvider.shouldShowInHome(
'giftcards'
);
const purchasedCards = await this.giftCardProvider.getPurchasedBrands();
this.purchasedBrands = _.uniqBy(purchasedCards, ([cards]) => cards.brand);
}
开发者ID:hcxiong,项目名称:copay,代码行数:7,代码来源:gift-cards-settings.ts
示例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);
}
开发者ID:gravitee-io,项目名称:gravitee-management-webui,代码行数:27,代码来源:dashboard-filter.controller.ts
示例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;
};
开发者ID:MayGo,项目名称:backer-timetracker,代码行数:25,代码来源:AnalyserForm.util.ts
示例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']
};
});
开发者ID:Hub-of-all-Things,项目名称:Rumpel,代码行数:8,代码来源:unbundle.pipe.ts
注:本文中的lodash.uniqBy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论