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

TypeScript underscore.shuffle函数代码示例

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

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



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

示例1: it

      it('correctly sorts parents', () => {
        const numberOfParents = simulateQueryData.results.categoryFacets[0].parentValues.length - 1;
        simulateQueryData.results.categoryFacets[0].values = [];
        simulateQueryData.results.categoryFacets[0].parentValues = shuffle(simulateQueryData.results.categoryFacets[0].parentValues);

        Simulate.query(test.env, simulateQueryData);

        verifyParents(numberOfParents);
      });
开发者ID:francoislg,项目名称:search-ui,代码行数:9,代码来源:CategoryFacetTest.ts


示例2: topCardsOfDeck

    // May trigger a shuffle
    topCardsOfDeck(game: Game, n: number) : CardInPlay[] {
        if (this.deck.count < n) {
            const reorderedDiscard = _.shuffle<CardInPlay>(this.discard.cards);
            game.moveCardsToBottom(reorderedDiscard, this.deck);

            game.log(`${this.name} shuffles`);
        }

        return _.last(this.deck.cards, n);
    }
开发者ID:scottostler,项目名称:conspirator,代码行数:11,代码来源:player.ts


示例3: modifyAddDuplicateLetters

function modifyAddDuplicateLetters(name: string): string {
    let lengthAvailable = characterConfig.MAX_NAME_LENGTH - name.length;
    const duplicationLetters: string[] = _.shuffle(DUPLICATION_LETTERS);
    for (let letter of duplicationLetters) {
        if (lengthAvailable > 0 && faker.random.boolean()) {
            name = name.replace(letter, letter + letter);
            lengthAvailable = characterConfig.MAX_NAME_LENGTH - name.length;
        }
    }
    return name;
}
开发者ID:Tzook,项目名称:lul,代码行数:11,代码来源:randomNames.ts


示例4: findNewcomers

 private async findNewcomers(current:DBBlock, filteringFunc: (joinData: { [pub:string]: any }) => Promise<{ [pub:string]: any }>) {
   const updates = {};
   const preJoinData = await this.getPreJoinData(current);
   const joinData = await filteringFunc(preJoinData);
   const members = await this.dal.getMembers();
   const wotMembers = _.pluck(members, 'pubkey');
   // Checking step
   let newcomers = _(joinData).keys();
   newcomers = _.shuffle(newcomers)
   const nextBlockNumber = current ? current.number + 1 : 0;
   try {
     const realNewcomers = await this.iteratedChecking(newcomers, async (someNewcomers:string[]) => {
       const nextBlock = {
         number: nextBlockNumber,
         joiners: someNewcomers,
         identities: _.filter(newcomers.map((pub:string) => joinData[pub].identity), { wasMember: false }).map((idty:any) => idty.pubkey)
       };
       const theNewLinks = await this.computeNewLinks(nextBlockNumber, someNewcomers, joinData, updates)
       await this.checkWoTConstraints(nextBlock, theNewLinks, current);
     })
     const newLinks = await this.computeNewLinks(nextBlockNumber, realNewcomers, joinData, updates);
     const newWoT = wotMembers.concat(realNewcomers);
     const finalJoinData: { [pub:string]: any } = {};
     realNewcomers.forEach((newcomer:string) => {
       // Only keep membership of selected newcomers
       finalJoinData[newcomer] = joinData[newcomer];
       // Only keep certifications from final members
       const keptCerts:any[] = [];
       joinData[newcomer].certs.forEach((cert:any) => {
         const issuer = cert.from;
         if (~newWoT.indexOf(issuer) && ~newLinks[cert.to].indexOf(issuer)) {
           keptCerts.push(cert);
         }
       });
       joinData[newcomer].certs = keptCerts;
     });
     return {
       current: current,
       newWotMembers: wotMembers.concat(realNewcomers),
       finalJoinData: finalJoinData,
       updates: updates
     }
   } catch(err) {
     this.logger.error(err);
     throw err;
   }
 }
开发者ID:Kalmac,项目名称:duniter,代码行数:47,代码来源:blockGenerator.ts


示例5: getMaxRepeatValue

export function getMaxRepeatValue (arr: Array<string>): string {
    var obj: MaxRepeatObject = {
        max: {
            count: 0, 
            value: ''
        }
    };

    _.shuffle(arr).forEach((val: string) => {
        obj[val] = obj[val] || 0;
        obj[val]++;
        
        if(obj[val] > obj.max.count) {
            obj.max.count = obj[val];
            obj.max.value = val;
        }
    });
    
    return obj.max.value;
}
开发者ID:andreevWork,项目名称:mafia,代码行数:20,代码来源:helpers.ts


示例6: RolesForPlayers

    export function RolesForPlayers(players: Array<Player>): Array<GamePlayer>{
        let steps: number = Math.floor((players.length - MIN_PLAYERS) / STEP_CHANGE_ROLES) + 1,
            game_players: Array<GamePlayer> = _.shuffle(players).map((player: Player) => _.extend({role: Roles.INHABITANT}, player)),
            flag_commissar = false,
            index: number = 0;

        game_players[index++].role = Roles.DOCTOR;
        game_players[index++].role = Roles.WHORE;

        while(steps--) {
            game_players[index++].role = Roles.MAFIA;

            if(steps % 2 !== 0) {
                if(!flag_commissar) {
                    game_players[index++].role = Roles.COMMISSAR;
                    flag_commissar = true;
                }
            }
        }

        return game_players;
    }
开发者ID:andreevWork,项目名称:mafia,代码行数:22,代码来源:Player.ts


示例7:

                .then(sourceItems => {
                    console.log("got all source's items", {sourceItems});
                    // sourceItems = sourceItems.map(items => items.slice(0, 5));
                    var candidateItems = _.flatten(sourceItems);

                    // take all the items returned by Python, check each to see if it's been
                    // colourised already, build a new array (to return to user) with those
                    var allItems = [];
                    candidateItems.forEach(item => {
                        const hash = crypto.createHash('md5');
                        hash.update(item.originalImageUrl);
                        const outputFile = hash.digest('hex') + '.jpg';

                        if (alreadyProcessedFiles[outputFile]) {
                            allItems.push(item);
                        }
                    });

                    console.log("flattened items", {allItems});
                    allItems = _.shuffle(allItems);
                    console.log("shuffled items", {allItems});
                    res.json({ items: allItems });
                })
开发者ID:colourful-past,项目名称:website,代码行数:23,代码来源:WebHandler.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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