本文整理汇总了TypeScript中lodash.keyBy函数的典型用法代码示例。如果您正苦于以下问题:TypeScript keyBy函数的具体用法?TypeScript keyBy怎么用?TypeScript keyBy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了keyBy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: exportDraft
async function exportDraft(access: Access, nameMap?: NameMap): Promise<DraftExport> {
const [_users, _golfers, draft, chatMessages] = await Promise.all([
getUsers(),
access.getGolfers(),
access.getDraft(),
access.getChatMessages()
]);
// Back-compat
ensureReplaceAllKeys(draft.picks, 'player', 'user');
ensureReplaceAllKeys(chatMessages, 'player', 'user');
const users = nameMap || keyBy(_users, u => u._id.toString());
const golfers = keyBy(_golfers, g => g._id.toString());
const draftPicks = sortBy(draft.picks, dp => dp.pickNumber).map(dp => ({
user: ensureTruthy(users[dp.user.toString()], `User not found: ${dp.user}`)['name'],
golfer: ensureTruthy(golfers[dp.golfer.toString()], `Golfer not found: ${dp.golfer}`)['name'],
pickNumber: dp.pickNumber
}));
const chatMessagesExport = sortBy(chatMessages, msg => msg.date).map(msg => ({
user: msg.user ? users[msg.user.toString()]['name'] : null,
isBot: !!msg.isBot,
message: msg.message,
date: msg.date.toISOString()
}));
return { draftPicks, chatMessages: chatMessagesExport };
}
开发者ID:odetown,项目名称:golfdraft,代码行数:30,代码来源:exportDraft.ts
示例2: handleLoadUserThreadsAction
function handleLoadUserThreadsAction(state: StoreData,
action: UserThreadsLoadedAction): StoreData {
return {
participants: _.keyBy(action.payload.participants, 'id'),
messages: _.keyBy(action.payload.messages, 'id'),
threads: _.keyBy(action.payload.threads, 'id')
};
}
开发者ID:MidoShahin,项目名称:Chat-App-using-ngrx-store,代码行数:8,代码来源:uiStoreDataReducer.ts
示例3: AuditQuery
vm.$onInit = ()=> {
vm.events = _.map(vm.events, (ev: string)=> {return ev.toUpperCase()});
vm.apisById = _.keyBy(vm.apis, "id");
vm.applicationsById = _.keyBy(vm.applications, "id");
vm.query = new AuditQuery();
vm.onPaginate = vm.onPaginate.bind(this);
AuditService.list(null, vm.api).then(response =>
vm.handleAuditResponseData(response.data)
);
};
开发者ID:gravitee-io,项目名称:gravitee-management-webui,代码行数:10,代码来源:audit.component.ts
示例4: makeGeneticTrackTooltip_getCoverageInformation
export function makeGeneticTrackTooltip_getCoverageInformation(
profiled_in: {genePanelId?:string, molecularProfileId:string}[]|undefined,
not_profiled_in: {genePanelId?:string, molecularProfileId:string}[]|undefined,
alterationTypesInQuery?: string[],
molecularProfileIdToMolecularProfile?: {[molecularProfileId:string]:MolecularProfile}
):{
dispProfiledGenePanelIds: string[];
dispNotProfiledGenePanelIds: string[];
dispProfiledIn: string[]|undefined;
dispNotProfiledIn: string[]|undefined;
dispAllProfiled:boolean;
dispNotProfiled:boolean;
} {
let dispProfiledGenePanelIds:string[] = [];
let dispProfiledGenePanelIdsMap:{[genePanelId:string]:string} = {};
let dispProfiledIn:string[]|undefined = undefined;
let dispProfiledInMap:{[molecularProfileId:string]:string} = {};
let dispNotProfiledIn:string[]|undefined = undefined;
let dispNotProfiledGenePanelIds:string[] = [];
let profiledInTypes:{[type:string]:string}|undefined = undefined;
if (profiled_in) {
dispProfiledGenePanelIds = _.uniq((profiled_in.map(x=>x.genePanelId) as (string|undefined)[]).filter(x=>!!x) as string[]);
dispProfiledIn = _.uniq(profiled_in.map(x=>x.molecularProfileId));
if (molecularProfileIdToMolecularProfile) {
profiledInTypes = _.keyBy(dispProfiledIn, molecularProfileId=>molecularProfileIdToMolecularProfile[molecularProfileId].molecularAlterationType);
}
dispProfiledInMap = _.keyBy(dispProfiledIn);
dispProfiledGenePanelIdsMap = _.keyBy(dispProfiledGenePanelIds);
}
if (not_profiled_in) {
dispNotProfiledIn = _.uniq(not_profiled_in.map(x=>x.molecularProfileId)).filter(x=>!dispProfiledInMap[x]); // filter out profiles in profiled_in to avoid confusing tooltip (this occurs e.g. w multiple samples, one profiled one not)
if (profiledInTypes && alterationTypesInQuery && molecularProfileIdToMolecularProfile) {
let notProfiledInTypes = _.keyBy(dispNotProfiledIn, molecularProfileId=>molecularProfileIdToMolecularProfile[molecularProfileId].molecularAlterationType);
// add an entry to 'not profiled in' for each alteration type in the query iff the sample is not profiled in a profile of that type, and that type is not already accounted for.
// This is for the case of multiple study query - eg one study has CNA profile, the other doesnt, and we want to show in a tooltip from the other study that
// the sample is not profiled for CNA. If the study actually has a CNA profile, then we wont show "not profiled for copy number alterations" because
// that will be filtered out below because its in profiledInTypes or notProfiledInTypes. Otherwise, CNA will be in alterationTypesInQuery,
// and it wont be covered in profiledInTypes or notProfiledInTypes, so it will make sense to say "copy number alterations" in that generality.
dispNotProfiledIn = dispNotProfiledIn.concat(alterationTypesInQuery.filter(t=>(!profiledInTypes![t] && !notProfiledInTypes[t])).map(t=>alterationTypeToProfiledForText[t]));
}
dispNotProfiledGenePanelIds = _.uniq(not_profiled_in.map(x=>x.genePanelId)).filter(x=>(!!x && !dispProfiledGenePanelIdsMap[x])) as string[] ;
}
const dispAllProfiled = !!(dispProfiledIn && dispProfiledIn.length && dispNotProfiledIn && !dispNotProfiledIn.length);
const dispNotProfiled = !!(dispNotProfiledIn && dispNotProfiledIn.length && dispProfiledIn && !dispProfiledIn.length);
return {
dispProfiledGenePanelIds, dispNotProfiledGenePanelIds, dispProfiledIn, dispNotProfiledIn, dispAllProfiled, dispNotProfiled
};
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:48,代码来源:TooltipUtils.ts
示例5: push
}).then(result => {
console.log(`Saving ${result.tracks.length} values`);
const tracks:Track[] = _.map(result.tracks, (t:Track) => {
const keyKml = push('kmls', t.kml).key;
t.kml = keyKml;
const keyTrack = push('tracks', _.omit(t, ['idMongo', 'idFirebase'])).key;
t.idFirebase = keyTrack;
return t;
});
const tracksByIdMongo = _.keyBy(tracks, t => t.idMongo);
const mongo2firebase = (id:string):string => {
if (!id) return null;
const track:Track = tracksByIdMongo[id];
if (!track) return null;
return track.idFirebase;
};
// convert loop ids from mongo to firebase
_.each(result.events, e => {
e.loop1 = mongo2firebase(e.loop1);
e.loop2 = mongo2firebase(e.loop2);
e.loop3 = mongo2firebase(e.loop3);
push('events', e);
});
}).catch((err:MongoError|firebase.FirebaseError)=> {
开发者ID:vincent314,项目名称:export-mongo-data,代码行数:29,代码来源:export.ts
示例6: function
export default function(state: Languages = {}, action: Action): Languages {
if (action.type === 'RECEIVE_LANGUAGES') {
return keyBy(action.languages, 'key');
}
return state;
}
开发者ID:flopma,项目名称:sonarqube,代码行数:7,代码来源:languages.ts
示例7: createAndMergeRouters
export function createAndMergeRouters(
kiln: IKiln,
routerMap: IRouterMap,
swaggerOverrides?: Partial<SwaggerSpec>,
): IRouter {
const models = keyBy(kiln.getModels(), kilnModel => kilnModel.name)
const router = express.Router()
const routes: IRouterRoute[] = []
forEach(routerMap, (routerOrOptions, prefix) => {
let subRouter = routerOrOptions as IRouter
if (!Array.isArray(routerOrOptions.routes)) {
const routerOptions = routerOrOptions as IRouterOptions
if (routerOptions.modelName) {
const kilnModel = models[routerOptions.modelName]
const databaseExtension = routerOptions.databaseExtension || DEFAULT_DATABASE_EXTENSION
const executor = kiln.build<IDatabaseExecutor>(routerOptions.modelName, databaseExtension)
subRouter = createRouter(routerOptions, kilnModel, executor)
} else {
subRouter = createRouter(routerOptions)
}
}
router.use(prefix, subRouter.router)
subRouter.routes.forEach(route => {
routes.push({...route, path: `${prefix}${route.path}`})
})
})
const mergedRouter = {router, routes}
const swagger = buildSpecification(kiln, mergedRouter, swaggerOverrides)
router.get('/swagger.json', createSwaggerSpecHandler(swagger))
router.get('/docs', createSwaggerUIHandler(swagger, './swagger.json'))
return mergedRouter
}
开发者ID:patrickhulce,项目名称:klay,代码行数:34,代码来源:create-router.ts
示例8: getIndexableCharts
export async function getIndexableCharts(): Promise<ChartItemWithTags[]> {
const chartItems = await db.query(`SELECT id, config->>"$.slug" AS slug, config->>"$.title" AS title FROM charts WHERE publishedAt IS NOT NULL`)
const chartTags = await db.query(`
SELECT ct.chartId, ct.tagId, t.name as tagName, t.parentId as tagParentId FROM chart_tags ct
JOIN charts c ON c.id=ct.chartId
JOIN tags t ON t.id=ct.tagId
`)
for (const c of chartItems) {
c.tags = []
}
const chartsById = _.keyBy(chartItems, c => c.id)
for (const ct of chartTags) {
// XXX hardcoded filtering to public parent tags
if ([1515, 1507, 1513, 1504, 1502, 1509, 1506, 1501, 1514, 1511, 1500, 1503, 1505, 1508, 1512, 1510].indexOf(ct.tagParentId) === -1)
continue
const c = chartsById[ct.chartId]
if (c)
c.tags.push({ id: ct.tagId, name: ct.tagName })
}
return chartItems
}
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:27,代码来源:grapherUtil.ts
示例9: keyBy
const reducer = (state: Languages = {}, action: any = {}) => {
if (action.type === RECEIVE_LANGUAGES) {
return keyBy(action.languages, 'key');
}
return state;
};
开发者ID:christophelevis,项目名称:sonarqube,代码行数:7,代码来源:reducer.ts
示例10: run
async run() {
this.logger.info(
`Getting exams for all modules in ${this.academicYear} semester ${this.semester}`,
);
const term = getTermCode(this.semester, this.academicYear);
// Make API requests to get the exam info
let rawExams: ModuleExam[];
try {
rawExams = await cacheDownload(
'exams',
() => this.api.getTermExams(term),
this.examCache,
this.logger,
);
} catch (e) {
throw new TaskError('Cannot get exam data', this, e);
}
// Try to filter out invalid exams
const [validExams, invalidExams] = partition(rawExams, (exam) =>
validateExam(exam, this.logger),
);
if (invalidExams.length > 0) {
this.logger.warn({ invalidExams }, `Removed invalid exams`);
}
const exams = mapValues(keyBy(validExams, (exam) => exam.module), mapExamInfo);
this.logger.info(`Downloaded ${rawExams.length} exams`);
return exams;
}
开发者ID:nusmodifications,项目名称:nusmods,代码行数:32,代码来源:GetSemesterExams.ts
示例11: populateSampleSpecificationsFromVirtualStudies
export function populateSampleSpecificationsFromVirtualStudies(samplesSpecification:SamplesSpecificationElement[], virtualStudies:VirtualStudy[]){
const virtualStudiesKeyedById = _.keyBy(virtualStudies,(virtualStudy)=>virtualStudy.id);
// remove specs for virtual studies (since they mean nothing to api)
// and then populate with ids
samplesSpecification = _.filter(samplesSpecification,(spec)=>!virtualStudiesKeyedById[spec.studyId]);
const allVirtualStudySampleSpecs = _.flatMapDeep(virtualStudies.map((virtualStudy)=>{
return virtualStudy.data.studies.map((study)=>{
return study.samples.map((sampleId)=>{
return {
studyId:study.id,
sampleListId:undefined,
sampleId:sampleId
} as SamplesSpecificationElement
})
}) as SamplesSpecificationElement[][];
}));
// ts not resolving type above and not sure why, so cast it
samplesSpecification = samplesSpecification.concat(allVirtualStudySampleSpecs as SamplesSpecificationElement[]);
return samplesSpecification;
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:26,代码来源:ResultsViewPageHelpers.ts
示例12: makeProfiledData
function makeProfiledData(
attribute: ExtendedClinicalAttribute,
samples:Sample[],
coverageInformation:CoverageInformation,
):ClinicalData[] {
const molecularProfileIds = attribute.molecularProfileIds!;
const ret = [];
for (const sample of samples) {
const coverageInfo = coverageInformation.samples[sample.uniqueSampleKey];
if (!coverageInfo) {
continue;
}
const allCoverage:{ molecularProfileId:string }[] =
(_.flatten(_.values(coverageInfo.byGene)) as { molecularProfileId:string }[]).concat(coverageInfo.allGenes);
const coveredMolecularProfiles = _.keyBy(allCoverage, "molecularProfileId");
const profiled = _.some(molecularProfileIds, molecularProfileId=>(molecularProfileId in coveredMolecularProfiles));
if (profiled) {
ret.push({
clinicalAttribute: attribute as ClinicalAttribute,
clinicalAttributeId: attribute.clinicalAttributeId,
patientId: sample.patientId,
sampleId: sample.sampleId,
studyId: sample.studyId,
uniquePatientKey: sample.uniquePatientKey,
uniqueSampleKey: sample.uniqueSampleKey,
value: "Yes"
});
}
}
return ret;
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:31,代码来源:ClinicalDataCache.ts
示例13: collectBadgesByGroup
return $q.all(_.map(assignableBadgePaths, (b) => adhHttp.get(b).then(extractBadge))).then((badges : any) => {
scope.badges = _.keyBy(badges, "path");
var groupPaths : string[] = _.union.apply(_, _.map(badges, "groups"));
return $q.all(_.map(groupPaths, (g) => adhHttp.get(g))).then((result) => {
scope.badgeGroups = _.keyBy(_.map(result, extractGroup), "path");
scope.badgesByGroup = collectBadgesByGroup(groupPaths, badges);
});
});
开发者ID:Janaba,项目名称:adhocracy3,代码行数:8,代码来源:Badge.ts
示例14: getMarketsInfo
export async function getMarketsInfo(db: Knex, augur: {}, params: t.TypeOf<typeof MarketsInfoParams>): Promise<UIMarketsInfo<string>> {
if (params.marketIds == null || ! _.isArray(params.marketIds) ) throw new Error("must include marketIds parameter");
const marketInfoComplete: Array<UIMarketInfo<string>> = await batchAndCombine(params.marketIds, _.partial(getUIMarketsInfo, db));
const marketsInfoByMarket = _.keyBy(marketInfoComplete, (r): string => r.id);
return _.map(params.marketIds, (marketId: string): UIMarketInfo<string>|null => {
return marketsInfoByMarket[marketId] || null;
});
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:8,代码来源:get-markets-info.ts
示例15: transitionFunction
function updateExpansionTracks<
TrackSpecType extends {key: string},
RuleSetRepMap
>(
nextParentSpec: {key: string, expansionTrackList?: TrackSpecType[]} | undefined,
prevParentSpec: {key: string, expansionTrackList?: TrackSpecType[]} | undefined,
getTrackSpecKeyToTrackId: () => {[key: string]: TrackId},
getMolecularProfileMap: () => (
{[molecularProfileId: string]: MolecularProfile} | undefined
),
oncoprint: OncoprintJS<any>,
nextProps: IOncoprintProps,
prevProps: Partial<IOncoprintProps>,
trackIdForRuleSetSharing: RuleSetRepMap,
transitionFunction: (
expansionTrackSpec: TrackSpecType | undefined,
prevExpansionTrackSpec: TrackSpecType,
getTrackSpecKeyToTrackId: () => {[key: string]: TrackId},
getMolecularProfileMap: () => (
{[molecularProfileId: string]: MolecularProfile} | undefined
),
oncoprint: OncoprintJS<any>,
nextProps: IOncoprintProps,
prevProps: Partial<IOncoprintProps>,
trackIdForRuleSetSharing: RuleSetRepMap,
expansionParentKey?: string
) => void
) {
const expansionTrackList = (prevParentSpec && prevParentSpec.expansionTrackList
? prevParentSpec.expansionTrackList
: []
);
const nextExpansionTracks = (nextParentSpec && nextParentSpec.expansionTrackList
? nextParentSpec.expansionTrackList
: []
);
const prevExpansionTracks = _.keyBy(expansionTrackList, track => track.key);
for (const track of nextExpansionTracks) {
// nextParentSpec cannot be undefined, or we wouldn't have entered
// this loop
transitionFunction(
track, prevExpansionTracks[track.key], getTrackSpecKeyToTrackId,
getMolecularProfileMap, oncoprint, nextProps, prevProps,
trackIdForRuleSetSharing, nextParentSpec!.key
);
delete prevExpansionTracks[track.key];
}
for (const track of expansionTrackList) {
if (prevExpansionTracks.hasOwnProperty(track.key)) {
// if its still there, then this track no longer exists
transitionFunction(
undefined, prevExpansionTracks[track.key], getTrackSpecKeyToTrackId,
getMolecularProfileMap, oncoprint, nextProps, prevProps,
trackIdForRuleSetSharing
);
}
}
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:58,代码来源:DeltaUtils.ts
示例16: transitionGeneticTrackOrder
function transitionGeneticTrackOrder(
nextProps:IOncoprintProps,
prevProps:Partial<IOncoprintProps>,
oncoprint:OncoprintJS<any>,
getTrackSpecKeyToTrackId:()=>{[key:string]:TrackId}
) {
const nextTracksMap = _.keyBy(nextProps.geneticTracks, "key");
const prevTracksMap = _.keyBy(prevProps.geneticTracks || [], "key");
const nextOrder = (nextProps.geneticTracksOrder || nextProps.geneticTracks.map(t=>t.key))
.filter(key=>(key in nextTracksMap));
const prevOrder = (prevProps.geneticTracksOrder || (prevProps.geneticTracks || []).map(t=>t.key))
.filter(key=>(key in prevTracksMap));
if (!_.isEqual(nextOrder, prevOrder)) {
const trackSpecKeyToTrackId = getTrackSpecKeyToTrackId();
oncoprint.setTrackGroupOrder(GENETIC_TRACK_GROUP_INDEX, nextOrder.map(key=>trackSpecKeyToTrackId[key]));
}
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:18,代码来源:DeltaUtils.ts
示例17: generateCaseAlterationData
export function generateCaseAlterationData(
selectedMolecularProfiles:MolecularProfile[],
caseAggregatedDataByOQLLine?: IQueriedCaseData<AnnotatedExtendedAlteration>[],
genePanelInformation?: CoverageInformation,
samples: Sample[] = [],
geneAlterationDataByGene?: {[gene: string]: IGeneAlteration},
molecularProfileIdToMolecularProfile?: {[molecularProfileId:string]:MolecularProfile}
): ICaseAlteration[] {
const caseAlterationData: {[studyCaseId: string] : ICaseAlteration} = {};
if (caseAggregatedDataByOQLLine &&
genePanelInformation)
{
// we need the sample index for better performance
const sampleIndex = _.keyBy(samples, 'uniqueSampleKey');
caseAggregatedDataByOQLLine.forEach(data => {
const geneticTrackData = makeGeneticTrackData(
data.cases.samples, data.oql.gene, samples, genePanelInformation, selectedMolecularProfiles);
geneticTrackData.forEach(datum => {
const studyId = datum.study_id;
const sampleId = datum.sample || (sampleIndex[datum.uid] ? sampleIndex[datum.uid].sampleId : "");
const key = studyId + ":" + datum.uid;
// initialize the row data
caseAlterationData[key] = caseAlterationData[key] || {
studyId,
sampleId,
patientId: sampleIndex[datum.uid] ? sampleIndex[datum.uid].patientId : "",
altered: false,
oqlData: {},
oqlDataByGene: {}
};
// update altered: a single alteration in any track means altered
caseAlterationData[key].altered = caseAlterationData[key].altered || datum.data.length > 0;
// for each track (for each oql line/gene) the oql data is different
// that's why we need a map here
const generatedOqlData = generateOqlData(datum, geneAlterationDataByGene, molecularProfileIdToMolecularProfile);
//generate and update oqlData in caseAlterationData
caseAlterationData[key].oqlData[data.oql.oql_line] = generatedOqlData
updateOqlData(datum, caseAlterationData[key].oqlData[data.oql.oql_line], molecularProfileIdToMolecularProfile);
//generate and update oqlDataByGene in caseAlterationData
if (caseAlterationData[key].oqlDataByGene[data.oql.gene] !== undefined) {
caseAlterationData[key].oqlDataByGene[data.oql.gene] = _.merge(generatedOqlData, caseAlterationData[key].oqlDataByGene[data.oql.gene]);
}
else {
caseAlterationData[key].oqlDataByGene[data.oql.gene] = generatedOqlData;
}
updateOqlData(datum, caseAlterationData[key].oqlDataByGene[data.oql.gene], molecularProfileIdToMolecularProfile);
});
});
}
return _.values(caseAlterationData);
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:57,代码来源:DownloadUtils.ts
示例18: getTypeDefinitionsByName
public getTypeDefinitionsByName(docAgnosticFormat: DocAgnosticFormat) {
if (_.isUndefined(this.sections.types)) {
return {};
}
const typeDocSection = docAgnosticFormat[this.sections.types];
const typeDefinitionByName = _.keyBy(typeDocSection.types, 'name');
return typeDefinitionByName;
}
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:9,代码来源:docs_info.ts
示例19:
adhHttp.get(scope.badgeablePath).then((proposal) => {
scope.poolPath = proposal.data[SIBadgeable.nick].post_pool;
scope.assignments = _.keyBy(assignments, "badgePath");
// The following object only contains the current assignments. In order to render the badge
// assignment UI, Assignment.html iterates over the available badges, though,
// and gives them the value checkboxes[badgePath], which is parsed to false when undefined.
scope.checkboxes = _.mapValues(scope.assignments, (v) => true);
});
开发者ID:Janaba,项目名称:adhocracy3,代码行数:9,代码来源:Badge.ts
示例20: it
it('should add lines below', () => {
const lines = keyBy(range(4, 19).map(line => mockSourceLine({ line })), 'line');
const snippets = [[lines[4], lines[5], lines[6], lines[7], lines[8]]];
const result = expandSnippet({ direction: 'down', lines, snippetIndex: 0, snippets });
expect(result).toHaveLength(1);
expect(result[0].map(l => l.line)).toEqual(range(4, 19));
});
开发者ID:SonarSource,项目名称:sonarqube,代码行数:9,代码来源:utils-test.ts
注:本文中的lodash.keyBy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论