當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript lodash.uniqBy函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。