当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.mapValues函数代码示例

本文整理汇总了TypeScript中lodash.mapValues函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mapValues函数的具体用法?TypeScript mapValues怎么用?TypeScript mapValues使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mapValues函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

 it(`${scenario.name}`, async () => {
   switch (scenario.id) {
     case 'nothing_space':
       // Saved Objects Managment is not available when everything is disabled.
       const nothingSpaceCapabilities = await uiCapabilitiesService.get({
         spaceId: scenario.id,
       });
       expect(nothingSpaceCapabilities.success).to.be(true);
       expect(nothingSpaceCapabilities.value).to.have.property('savedObjectsManagement');
       const nothingSpaceExpected = mapValues(
         nothingSpaceCapabilities.value!.savedObjectsManagement,
         () => savedObjectsManagementBuilder.uiCapabilities('none')
       );
       expect(nothingSpaceCapabilities.value!.savedObjectsManagement).to.eql(
         nothingSpaceExpected
       );
       break;
     default:
       // Otherwise it's available without restriction
       const uiCapabilities = await uiCapabilitiesService.get({ spaceId: scenario.id });
       expect(uiCapabilities.success).to.be(true);
       expect(uiCapabilities.value).to.have.property('savedObjectsManagement');
       const expected = mapValues(uiCapabilities.value!.savedObjectsManagement, () =>
         savedObjectsManagementBuilder.uiCapabilities('all')
       );
       expect(uiCapabilities.value!.savedObjectsManagement).to.eql(expected);
   }
 });
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: getAllOutcomesProfitLoss

export async function getAllOutcomesProfitLoss(db: Knex, params: GetProfitLossParamsType): Promise<AllOutcomesProfitLoss> {
  const { profits, outcomeValues, buckets, lastTradePriceMinusMinPrice24hAgoByOutcomeByMarketId, oldestTradePriceMinusMinPriceUserPaidForOpenPositionInLast24hByOutcomeByMarketId } = await getProfitLossData(db, params);

  const bucketedProfits = _.mapValues(profits, (pls, marketId) => {
    return bucketAtTimestamps<ProfitLossTimeseries>(pls, buckets, Object.assign(getDefaultPLTimeseries(), { marketId }));
  });

  const bucketedOutcomeValues = _.mapValues(outcomeValues, (marketOutcomeValues) => {
    return bucketAtTimestamps<OutcomeValueTimeseries>(marketOutcomeValues, buckets, getDefaultOVTimeseries());
  });

  const profit = _.mapValues(bucketedProfits, (pls, marketId) => {
    return getProfitResultsForMarket(pls, bucketedOutcomeValues[marketId], buckets, lastTradePriceMinusMinPrice24hAgoByOutcomeByMarketId, oldestTradePriceMinusMinPriceUserPaidForOpenPositionInLast24hByOutcomeByMarketId);
  });

  const marketOutcomes = _.fromPairs(_.values(_.mapValues(profits, (pls) => {
    const first = _.first(_.first(_.values(pls)))!;
    return [first.marketId, first.numOutcomes];
  })));

  return {
    profit,
    marketOutcomes,
    buckets,
  };
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:26,代码来源:get-profit-loss.ts

示例3: run

  async run(input: Input) {
    this.logger.info(`Collating venues for ${this.academicYear} semester ${this.semester}`);

    // Insert module code and flatten lessons
    const venueLessons: LessonWithModuleCode[] = flatMap(input, (module) =>
      module.semesterData.timetable.map(
        (lesson: RawLesson): LessonWithModuleCode => ({
          ...lesson,
          moduleCode: module.moduleCode,
        }),
      ),
    );

    const venues = extractVenueAvailability(venueLessons);

    // Get a mapping of module code to module title to help with module aliasing
    const moduleCodeToTitle: { [moduleCode: string]: ModuleTitle } = {};
    input.forEach((module) => {
      moduleCodeToTitle[module.moduleCode] = module.module.title;
    });

    // Merge dual-coded modules and extract the aliases generated for use later
    const allAliases: ModuleAliases = {};
    for (const venue of values(venues)) {
      for (const availability of venue) {
        const { lessons, aliases } = mergeDualCodedModules(availability.classes);
        availability.classes = lessons;

        // Merge the alias mappings
        for (const [moduleCode, alias] of entries(aliases)) {
          // Only add the modules as alias if they have the same title
          const title = moduleCodeToTitle[moduleCode];
          const filteredAliases = Array.from(alias).filter(
            (module) => title === moduleCodeToTitle[module],
          );

          if (filteredAliases.length) {
            allAliases[moduleCode] = union(
              allAliases[moduleCode] || new Set(),
              new Set(filteredAliases),
            );
          }
        }
      }
    }

    // Save the results
    const outputAliases = mapValues(allAliases, (moduleCodes) => Array.from(moduleCodes));
    const venueList = Object.keys(venues);

    await Promise.all([
      this.io.venueInformation(this.semester, venues),
      this.io.venueList(this.semester, venueList),
      this.aliasCache.write(mapValues(outputAliases, (set): string[] => Array.from(set))),
    ]);

    return { venues, aliases: allAliases };
  }
开发者ID:nusmodifications,项目名称:nusmods,代码行数:58,代码来源:CollateVenues.ts

示例4: it

        it('undefined nested values in new settings should be ignored', () => {
            const newSettings: SettingsPartial<any> = {
                filterOptions: _.mapValues(allSettings.filterOptions, _.constant(undefined)),
                dataOptions: _.mapValues(allSettings.dataOptions, _.constant(undefined)),
                groupOptions: _.mapValues(allSettings.groupOptions, _.constant(undefined))
            };

            const actual = Settings.merge(allSettings, newSettings);
            expect(actual).toEqualPlainObject(allSettings);
        });
开发者ID:QuBaR,项目名称:ng-table,代码行数:10,代码来源:settings.spec.ts

示例5: getRefPaths

function getRefPaths(obj: object, paths: { [key: string]: any }): { [key: string]: string } {

	// pick because it's an object (map)
	const singleRefsFiltered = pickBy(paths, schemaType => schemaType.options && schemaType.options.ref);
	const singleRefs = mapValues(singleRefsFiltered, schemaType => schemaType.options.ref);

	const arrayRefsFiltered = pickBy(paths, schemaType => schemaType.caster && schemaType.caster.instance && schemaType.caster.options && schemaType.caster.options.ref);
	const arrayRefs = mapValues(arrayRefsFiltered, schemaType => schemaType.caster.options.ref);

	return explodePaths(obj, singleRefs, arrayRefs);
}
开发者ID:freezy,项目名称:node-vpdb,代码行数:11,代码来源:pretty.id.plugin.ts

示例6: locatonExtractor

export function locatonExtractor(text: string): any {
  const allPhrases = createTokens(text);
  // console.log('allPhrases', allPhrases);
  const matchingCities = _.mapValues(locations, topic =>
    _.pickBy(topic, (value: Array<string>, key: string) => {
      const theseCities = value.map(location => location.toLowerCase());
      // console.log(theseCities);
      return _.intersection(allPhrases, theseCities).length > 0;
    }));
  // console.log('matchingCities', matchingCities);
  const pickedTopics = _.pickBy(matchingCities, topic => _.keys(topic).length > 0);
  const mapped = _.mapValues(pickedTopics, topic => _.keys(topic));
  // console.log(matchingCities);
  return mapped as locationMap;
}
开发者ID:fyndme,项目名称:bot-framework,代码行数:15,代码来源:helpers.ts

示例7: fetch

async function fetch(
    queries:IQuery[],
    sampleFilterByProfile: SampleFilterByProfile
): Promise<AugmentedData<GenesetMolecularData[], IQuery>[]> {
    const genesetIdsByProfile = _.mapValues(
        _.groupBy(queries, q => q.molecularProfileId),
        profileQueries => profileQueries.map(q => q.genesetId)
    );
    const params = Object.keys(genesetIdsByProfile)
        .map(profileId => ({
            geneticProfileId: profileId,
            // the Swagger-generated type expected by the client method below
            // incorrectly requires both samples and a sample list;
            // use 'as' to tell TypeScript that this object really does fit.
            // tslint:disable-next-line: no-object-literal-type-assertion
            genesetDataFilterCriteria: {
                genesetIds: genesetIdsByProfile[profileId],
                ...sampleFilterByProfile[profileId]
            } as GenesetDataFilterCriteria
        })
    );
    const dataPromises = params.map(param => client.fetchGeneticDataItemsUsingPOST(param));
    const results: GenesetMolecularData[][] = await Promise.all(dataPromises);
    return augmentQueryResults(queries, results);
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:25,代码来源:GenesetMolecularDataCache.ts


注:本文中的lodash.mapValues函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。