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

TypeScript underscore.findIndex函数代码示例

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

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



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

示例1: addAnchorTag

    /** !ReferenceCollection/addAnchorTag
     * ## Add Anchor Tag
     * Add Anchor Tag to the appropriate subcollection by
     * recursively skiming the collection and subcollections 
     * to place anchor in the correct place.
     */
    public addAnchorTag(anchorTag: string[], fileName: string, lineNumber: number): void {
        logger.debug("processing new anchorTag: " + JSON.stringify(anchorTag));
        if (anchorTag.length === 1) {
            logger.debug("Adding anchor tag:" + anchorTag[0]);
            this.addAnchor({
                id: anchorTag[0],
                line: lineNumber,
                file: fileName
            });
            return;
        } else {
            let collectionTag = anchorTag.shift();

            let i = findIndex(this.subcollections, (item) => {
                return item.id === collectionTag;
            });

            if (i > -1) {
            logger.debug("Collection present:" + collectionTag);

            return this.subcollections[i].addAnchorTag(anchorTag, fileName, lineNumber);
            } else {
                logger.debug("Collection not present:" + collectionTag);
                let newSubCollection = new ReferenceCollection(collectionTag);
                newSubCollection.addAnchorTag(anchorTag, fileName, lineNumber);
                this.addSubcollection(newSubCollection);
                return;
            }
        }
    }
开发者ID:JosephWebster,项目名称:duly-noted,代码行数:36,代码来源:referenceCollection.ts


示例2: remove

  vm.remove = function remove(item, $event) {
    if (!vm.loadout) {
      return;
    }
    const discriminator = item.type.toLowerCase();
    const typeInventory = vm.loadout.items[discriminator] = (vm.loadout.items[discriminator] || []);

    const index = _.findIndex(typeInventory, (i) => {
      return i.hash === item.hash && i.id === item.id;
    });

    if (index >= 0) {
      const decrement = $event.shiftKey ? 5 : 1;
      item.amount -= decrement;
      if (item.amount <= 0) {
        typeInventory.splice(index, 1);
      }
    }

    if (item.equipped && typeInventory.length > 0) {
      typeInventory[0].equipped = true;
    }

    vm.recalculateStats();
  };
开发者ID:delphiactual,项目名称:DIM,代码行数:25,代码来源:loadout-drawer.component.ts


示例3: HandleAsync

    async HandleAsync(request: JoinIdeaRequest): Promise<JoinIdeaResponse> {

        let businessRules = nconf.get("BusinessRules");

        let idea = await this.GetIdea(request.ideaId);

        if (idea.joinedList.length >= businessRules.MaxTeamSize) {
            throw new Error(`This project already has ${businessRules.MaxTeamSize} team members. ` +
                "Please select a different project.");
        }

        let ideas = await this.GetIdeasThatUserAlreadyJoined(request.user);
        ideas.map(async (idea) => {
            await this.UnJoinIdea(idea.id, request.user);
        });

        var index = _.findIndex(idea.joinedList, item => item.id === request.user.id);
        if (index < 0) {
            idea.joinedList.push({
                id: request.user.id,
                name: request.user.displayName,
                login: request.user.username
            });
        }

        await this.UpsertIdea(idea, request.user);

        return new JoinIdeaResponse();
    }
开发者ID:hakant,项目名称:HackathonPlannerAPI,代码行数:29,代码来源:JoinIdea.ts


示例4:

 .then(idea => {
     var index = _.findIndex(idea.joinedList, item => item.id === user.id);
     if (index > -1) {
         idea.joinedList.splice(index, 1);
     }
     return idea;
 }).then(idea => {
开发者ID:hakant,项目名称:HackathonPlannerAPI,代码行数:7,代码来源:IdeaRepository.ts


示例5:

      .then((loadouts) => {
        const index = _.findIndex(loadouts, { id: loadout.id });
        if (index >= 0) {
          loadouts.splice(index, 1);
        }

        return SyncService.remove(loadout.id!.toString()).then(() => loadouts) as IPromise<Loadout[]>;
      })
开发者ID:delphiactual,项目名称:DIM,代码行数:8,代码来源:loadout.service.ts


示例6: uuidv4

      .then((loadouts) => {
        if (!_.has(loadout, 'id')) {
          loadout.id = uuidv4();
        }

        // Handle overwriting an old loadout
        const existingLoadoutIndex = _.findIndex(loadouts, { id: loadout.id });
        if (existingLoadoutIndex > -1) {
          loadouts[existingLoadoutIndex] = loadout;
        } else {
          loadouts.push(loadout);
        }

        return saveLoadouts(loadouts);
      })
开发者ID:delphiactual,项目名称:DIM,代码行数:15,代码来源:loadout.service.ts


示例7: getBonus

      _.map(itemDef.stats, (stat: any) => {
        const def = statDefs.get(stat.statHash);
        if (!def) {
          return undefined;
        }

        const identifier = def.statIdentifier;

        // Only include these hidden stats, in this order
        const secondarySort = ['STAT_AIM_ASSISTANCE', 'STAT_EQUIP_SPEED'];
        let secondaryIndex = -1;

        let sort = _.findIndex(item.stats, { statHash: stat.statHash });
        let itemStat;
        if (sort < 0) {
          secondaryIndex = secondarySort.indexOf(identifier);
          sort = 50 + secondaryIndex;
        } else {
          itemStat = item.stats[sort];
          // Always at the end
          if (identifier === 'STAT_MAGAZINE_SIZE' || identifier === 'STAT_ATTACK_ENERGY') {
            sort = 100;
          }
        }

        if (!itemStat && secondaryIndex < 0) {
          return undefined;
        }

        let maximumValue = 100;
        if (itemStat && itemStat.maximumValue) {
          maximumValue = itemStat.maximumValue;
        }

        const val: number = itemStat ? itemStat.value : stat.value;
        let base = val;
        let bonus = 0;

        if (item.primaryStat && item.primaryStat.stat.statIdentifier === 'STAT_DEFENSE') {
          if (
            (identifier === 'STAT_INTELLECT' &&
              _.find(armorNodes, { hash: 1034209669 /* Increase Intellect */ })) ||
            (identifier === 'STAT_DISCIPLINE' &&
              _.find(armorNodes, { hash: 1263323987 /* Increase Discipline */ })) ||
            (identifier === 'STAT_STRENGTH' &&
              _.find(armorNodes, { hash: 193091484 /* Increase Strength */ }))
          ) {
            bonus = getBonus(item.primaryStat.value, type);

            if (
              activeArmorNode &&
              ((identifier === 'STAT_INTELLECT' && activeArmorNode.hash === 1034209669) ||
                (identifier === 'STAT_DISCIPLINE' && activeArmorNode.hash === 1263323987) ||
                (identifier === 'STAT_STRENGTH' && activeArmorNode.hash === 193091484))
            ) {
              base = Math.max(0, val - bonus);
            }
          }
        }

        const dimStat: D1Stat = {
          base,
          bonus,
          statHash: stat.statHash,
          name: def.statName,
          id: def.statIdentifier,
          sort,
          value: val,
          maximumValue,
          bar: identifier !== 'STAT_MAGAZINE_SIZE' && identifier !== 'STAT_ATTACK_ENERGY' // energy == magazine for swords
        };
        return dimStat;
      })
开发者ID:bhollis,项目名称:DIM,代码行数:73,代码来源:d1-item-factory.service.ts


示例8: getDefinitions

  getDefinitions().then((defs) => {
    extend(vm, {
      active: 'titan',
      i18nClassNames: _.object(
        ['titan', 'hunter', 'warlock'],
        _.sortBy(Object.values(defs.Class), (classDef) => classDef.classType).map(
          (c) => c.className
        )
      ),
      i18nItemNames: _.object(
        ['Helmet', 'Gauntlets', 'Chest', 'Leg', 'ClassItem', 'Artifact', 'Ghost'],
        [45, 46, 47, 48, 49, 38, 39].map((key) => defs.ItemCategory.get(key).title)
      ),
      activesets: '5/5/2',
      type: 'Helmet',
      scaleType: 'scaled',
      progress: 0,
      fullMode: false,
      includeVendors: false,
      showBlues: false,
      showExotics: true,
      showYear1: false,
      allSetTiers: [],
      hasSets: true,
      highestsets: {},
      activeHighestSets: [],
      ranked: {},
      activePerks: {},
      excludeditems: [],
      collapsedConfigs: [false, false, false, false, false, false, false, false, false, false],
      lockeditems: {
        Helmet: null,
        Gauntlets: null,
        Chest: null,
        Leg: null,
        ClassItem: null,
        Artifact: null,
        Ghost: null
      },
      lockedperks: {
        Helmet: {},
        Gauntlets: {},
        Chest: {},
        Leg: {},
        ClassItem: {},
        Artifact: {},
        Ghost: {}
      },
      setOrderValues: ['-str_val', '-dis_val', '-int_val'],
      lockedItemsValid(droppedId: string, droppedType: ArmorTypes) {
        droppedId = getId(droppedId);
        if (alreadyExists(vm.excludeditems, droppedId)) {
          return false;
        }

        const item = getItemById(droppedId, droppedType)!;
        const startCount: number = item.isExotic && item.type !== 'ClassItem' ? 1 : 0;
        return (
          startCount +
            (droppedType !== 'Helmet' && vm.lockeditems.Helmet && vm.lockeditems.Helmet.isExotic
              ? 1
              : 0) +
            (droppedType !== 'Gauntlets' &&
            vm.lockeditems.Gauntlets &&
            vm.lockeditems.Gauntlets.isExotic
              ? 1
              : 0) +
            (droppedType !== 'Chest' && vm.lockeditems.Chest && vm.lockeditems.Chest.isExotic
              ? 1
              : 0) +
            (droppedType !== 'Leg' && vm.lockeditems.Leg && vm.lockeditems.Leg.isExotic ? 1 : 0) <
          2
        );
      },
      excludedItemsValid(droppedId: string, droppedType: ArmorTypes) {
        const lockedItem = vm.lockeditems[droppedType];
        return !(lockedItem && alreadyExists([lockedItem], droppedId));
      },
      onSelectedChange(prevIdx, selectedIdx) {
        if (vm.activeCharacters[prevIdx].class !== vm.activeCharacters[selectedIdx].class) {
          vm.active = vm.activeCharacters[selectedIdx].class;
          vm.onCharacterChange();
          vm.selectedCharacter = selectedIdx;
        }
      },
      onCharacterChange() {
        vm.ranked = getActiveBuckets(
          buckets[vm.active],
          vendorBuckets[vm.active],
          vm.includeVendors
        );
        vm.activeCharacters = D1StoresService.getStores().filter((s) => !s.isVault);
        const activeStore = D1StoresService.getActiveStore()!;
        vm.selectedCharacter = _.findIndex(
          vm.activeCharacters,
          (char) => char.id === activeStore.id
        );
        vm.activePerks = getActiveBuckets(
          perks[vm.active],
          vendorPerks[vm.active],
//.........这里部分代码省略.........
开发者ID:bhollis,项目名称:DIM,代码行数:101,代码来源:loadout-builder.component.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript underscore.findWhere函数代码示例发布时间:2022-05-25
下一篇:
TypeScript underscore.find函数代码示例发布时间: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