• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript underscore.compact函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: mergeVendors

 .then((vendors) => {
   const nonNullVendors = _.compact(vendors);
   if (nonNullVendors.length) {
     const mergedVendor = mergeVendors(_.compact(vendors));
     service.vendors[mergedVendor.hash] = mergedVendor;
   } else {
     delete service.vendors[vendorDef.hash];
   }
 });
开发者ID:bhollis,项目名称:DIM,代码行数:9,代码来源:vendor.service.ts


示例2: buildHiddenStats

function buildHiddenStats(itemDef: DestinyInventoryItemDefinition, statDefs: LazyDefinition<DestinyStatDefinition>): DimStat[] {
  const itemStats = itemDef.stats.stats;

  if (!itemStats) {
    return [];
  }

  return _.compact(_.map(itemStats, (stat: DestinyInventoryItemStatDefinition): DimStat | undefined => {
    const def = statDefs.get(stat.statHash);

    // only aim assist and zoom for now
    if (![1345609583, 3555269338, 2715839340].includes(stat.statHash) || !stat.value) {
      return undefined;
    }

    return {
      base: stat.value,
      bonus: 0,
      statHash: stat.statHash,
      name: def.displayProperties.name,
      id: stat.statHash,
      sort: statWhiteList.indexOf(stat.statHash),
      value: stat.value,
      maximumValue: 100,
      bar: true
    };
  }));
}
开发者ID:delphiactual,项目名称:DIM,代码行数:28,代码来源:d2-item-factory.service.ts


示例3: buildDefaultStats

function buildDefaultStats(itemDef: DestinyInventoryItemDefinition, statDefs: LazyDefinition<DestinyStatDefinition>): DimStat[] {
  const itemStats = itemDef.stats.stats;

  if (!itemStats) {
    return [];
  }

  return _.compact(_.map(itemStats, (stat: DestinyInventoryItemStatDefinition): DimStat | undefined => {
    const def = statDefs.get(stat.statHash);

    if (!statWhiteList.includes(stat.statHash) || !stat.value) {
      return undefined;
    }

    return {
      base: stat.value,
      bonus: 0,
      statHash: stat.statHash,
      name: def.displayProperties.name,
      id: stat.statHash,
      sort: statWhiteList.indexOf(stat.statHash),
      value: stat.value,
      maximumValue: 100,
      bar: stat.statHash !== 4284893193 &&
        stat.statHash !== 3871231066 &&
        stat.statHash !== 2961396640
    };
  })) as DimStat[];
}
开发者ID:delphiactual,项目名称:DIM,代码行数:29,代码来源:d2-item-factory.service.ts


示例4: buildStats

function buildStats(
  item: DestinyItemComponent,
  stats: { [key: string]: DestinyItemStatsComponent },
  statDefs: LazyDefinition<DestinyStatDefinition>
): DimStat[] {
  if (!item.itemInstanceId || !stats[item.itemInstanceId]) {
    return [];
  }
  const itemStats = stats[item.itemInstanceId].stats;

  return _.compact(_.map(itemStats, (stat: DestinyStat): DimStat | undefined => {
    const def = statDefs.get(stat.statHash);
    const itemStat = itemStats[stat.statHash];
    if (!def || !itemStat) {
      return undefined;
    }

    const val = itemStat ? itemStat.value : stat.value;

    return {
      base: val,
      bonus: 0,
      statHash: stat.statHash,
      name: def.displayProperties.name,
      id: stat.statHash,
      sort: statWhiteList.indexOf(stat.statHash),
      value: val,
      maximumValue: itemStat.maximumValue,
      bar: stat.statHash !== 4284893193 &&
      stat.statHash !== 3871231066 &&
      stat.statHash !== 2961396640
    };
  }));
}
开发者ID:delphiactual,项目名称:DIM,代码行数:34,代码来源:d2-item-factory.service.ts


示例5: buildInvestmentStats

function buildInvestmentStats(
  itemStats: DestinyItemInvestmentStatDefinition[],
  statDefs: LazyDefinition<DestinyStatDefinition>
): DimStat[] {
  return _.compact(_.map(itemStats, (itemStat): DimStat | undefined => {
    const def = statDefs.get(itemStat.statTypeHash);
    /* 1935470627 = Power */
    if (!def || !itemStat || itemStat.statTypeHash === 1935470627) {
      return undefined;
    }

    return {
      base: itemStat.value,
      bonus: 0,
      statHash: itemStat.statTypeHash,
      name: def.displayProperties.name,
      id: itemStat.statTypeHash,
      sort: statWhiteList.indexOf(itemStat.statTypeHash),
      value: itemStat.value,
      maximumValue: 0,
      bar: def.hash !== 4284893193 &&
        def.hash !== 3871231066 &&
        def.hash !== 2961396640
    };
  }));
}
开发者ID:delphiactual,项目名称:DIM,代码行数:26,代码来源:d2-item-factory.service.ts


示例6: copy

      const farm = () => {
        const consolidateHashes = [
          417308266, // three of coins
          211861343, // heavy ammo synth
          928169143, // special ammo synth
          2180254632 // primary ammo synth
        ];

        this.consolidate = _.compact(
          consolidateHashes.map((hash) => {
            const ret = copy(
              D1StoresService.getItemAcrossStores({
                hash
              })
            );
            if (ret) {
              ret.amount = sum(D1StoresService.getStores(), (s) => s.amountOfItem(ret));
            }
            return ret;
          })
        );

        this.farmItems().then(() => {
          if (settings.farming.makeRoomForItems) {
            this.makeRoomForItems();
          }
        });
      };
开发者ID:bhollis,项目名称:DIM,代码行数:28,代码来源:farming.service.ts


示例7: getNotificationObjectByGerritEvent

function getNotificationObjectByGerritEvent(event: GerritEvent): NotificationObject {
    let gerritEventFormatter: GerritEventFormatter = getGerritEventFormatter(event);

    if (!gerritEventFormatter) {
        return null;
    }

    let text = di.inject(gerritEventFormatter.text, event)();
    let url = di.inject(gerritEventFormatter.getUrl, event)();
    let authorIcon = di.inject(gerritEventFormatter.getAuthorIcon, event)();

    let rows = _.compact(text.split('\n').map((row) => row.trim()));

    let title = rows[0];
    let subtitle = rows[1];
    let message = rows.splice(2).join('\n');

    return {
        title,
        subtitle,
        message,
        url,
        authorIconPath: authorIcon ? path.join(__dirname, '../../../images/', authorIcon) : null
    } as NotificationObject;
}
开发者ID:adasq,项目名称:gerrit-native-notifications,代码行数:25,代码来源:to-notification-object.ts


示例8:

 categoryItems.forEach((saleItem) => {
   const item = saleItem.item;
   if (
     item.bucket.sort === 'Weapons' ||
     item.bucket.sort === 'Armor' ||
     item.type === 'Artifact' ||
     item.type === 'Ghost'
   ) {
     if (item.talentGrid) {
       item.dtrRoll = _.compact(item.talentGrid.nodes.map((i) => i.dtrRoll)).join(';');
     }
     hasArmorWeaps = true;
   }
   if (item.type === 'Ship' || item.type === 'Vehicle') {
     hasVehicles = true;
   }
   if (item.type === 'Emblem' || item.type === 'Shader') {
     hasShadersEmbs = true;
   }
   if (item.type === 'Emote') {
     hasEmotes = true;
   }
   if (item.type === 'Material' || item.type === 'Consumable') {
     hasConsumables = true;
   }
   if (item.type === 'Bounties') {
     hasBounties = true;
   }
 });
开发者ID:bhollis,项目名称:DIM,代码行数:29,代码来源:vendor.service.ts


示例9:

 _.each(D1Categories, (types, category) => {
   buckets.byCategory[category] = _.compact(
     types.map((type) => {
       return buckets.byType[type];
     })
   );
 });
开发者ID:bhollis,项目名称:DIM,代码行数:7,代码来源:d1-buckets.service.ts


示例10: getBreadcrumbTooltip

 public getBreadcrumbTooltip(): string {
   const tooltipParts = [
     this.facet.getValueCaption(this.facetValue),
     this.facetValue.getFormattedCount(),
     this.facetValue.getFormattedComputedField(this.facet.options.computedFieldFormat)
   ];
   return _.compact(tooltipParts).join(' ');
 }
开发者ID:erocheleau,项目名称:search-ui,代码行数:8,代码来源:BreadcrumbValueElement.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript underscore.contains函数代码示例发布时间:2022-05-25
下一篇:
TypeScript underscore.clone函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap