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

TypeScript random.Random类代码示例

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

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



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

示例1: ballComponent

	ballComponent(): { key: string, frame?: string, animation?: { frame: string, frames: string[], speed: number } } {
		const ballImage = Random.choice(
			[
				'abdellah',
				'cedric',
				'christian',
				'christophe',
				'david',
				'eugenie',
				'francois',
				'jm',
				'jeff',
				'julien',
				'luc',
				'macarena',
				'mathieu',
				'sarah',
				'stephane',
				'sylvain',
				'vincent',
				'yanick',
				'yannick'
			]
		);

		return {
			key: 'devalto-skin',
			frame: 'ball-' + ballImage
		};
	}
开发者ID:clesquir,项目名称:js-volemon,代码行数:30,代码来源:DevaltoSkin.ts


示例2: function

  invite: function (user: Invitation) {
    // check(partyId, String);
    // check(userId, String);

    // let party = Parties.findOne(partyId);

    // if (!party)
    //   throw new Meteor.Error('404', 'No such party!');

    // if (party.public)
    //   throw new Meteor.Error('400', 'That party is public. No need to invite people.');

    // if (party.owner !== this.userId)
    //   throw new Meteor.Error('403', 'No permissions!');

      // Parties.update(partyId, {$addToSet: {invited: userId}});
      let token = Random.hexString( 16 );
      let message = {
        subject: "Invitation",
        text: `Hi, I just invited you to be an user in my brand new app!.
                        \n\nCome check it out: ${Meteor.absoluteUrl()}acceptinvitation/${token}\n`
      };

      Invitations.insert({
      // company: ['', Validators.required],
      company: user.company,
      name: user.name,
      last_name: user.last_name,
      email: user.email,
      role: user.role,
      phone: user.phone,
      address: user.address,
      city: user.city,
      state: user.state,
      postal_code: user.postal_code,
      token: token,
      invitation_date: user.invitation_date,
      message: message,
      invited_by: Meteor.userId
    });
      let _from = "[email protected]";
      let to = user.email;
      
      // console.log(to, Meteor.isServer, user, token);
      if (Meteor.isServer && to) {
        Email.send({
          from: _from,
          to: to,
          replyTo: _from || undefined,
          subject: message.subject,
          text: message.text
        });
        // console.log(token);
      }
  },
开发者ID:p3140,项目名称:angular2-meteor-starter-kit,代码行数:55,代码来源:methods.ts


示例3: randomBonus

	static randomBonus(gameConfiguration: GameConfiguration): BaseBonus {
		let availableBonuses = this.availableBonuses();

		if (gameConfiguration.overridesAvailableBonuses()) {
			availableBonuses = gameConfiguration.availableBonuses();
		}

		const bonus = this.fromClassName(Random.choice(availableBonuses));

		if (bonus instanceof RandomBonus) {
			let availableBonusesForRandom = this.availableBonusesForRandom();

			if (gameConfiguration.overridesAvailableBonusesForRandom()) {
				availableBonusesForRandom = gameConfiguration.availableBonusesForRandom();
			}

			bonus.setRandomBonus(this.fromClassName(Random.choice(availableBonusesForRandom)));
		}

		return bonus;
	}
开发者ID:clesquir,项目名称:js-volemon,代码行数:21,代码来源:BonusFactory.ts


示例4: constructor

 constructor () {
   this.isCartVisible = false;
   if(localStorage.getItem("user_id") == null) {
       localStorage.setItem("user_id", Random.id());
   }
 }
开发者ID:Apetrich,项目名称:square-meter,代码行数:6,代码来源:cart.ts


示例5: function

	addUserProject: function(projectId: string, userEmail: string) {
		let hasCreateUser = false;
		if (Meteor.isServer) {
			check(userEmail, String);
			check(projectId, String);

			let project = Projects.findOne(projectId);
			let user = Meteor.user();
			
			let pass = Random.id(8);

			if (!user || !project) {
				throw new Meteor.Error('403', 'not-authorized');
			}
			if (user._id !== project.owner) {
				throw new Meteor.Error('403', 'not-authorized');
			}

			let userAdd = Meteor.users.findOne({ 'emails.0.address': userEmail });
			if (!userAdd) {
				let userId = Accounts.createUser({ email: userEmail, password: pass });
				userAdd = Meteor.users.findOne(userId);
				if (!userAdd) {
					throw new Meteor.Error('404', 'user-not-found');
				}
				hasCreateUser = true;
			}
			let isIn = false;
			project.users.forEach((userP) => {
				if (userP.userId === userAdd._id) {
					isIn = true;
				}
			});
			if (!isIn) {
				Projects.update(projectId, {
					$push: {
						users: {
							email: userEmail,
							userId: userAdd._id
						}
					}
				});
			}
			this.unblock();
			if (Meteor.isServer && hasCreateUser) {
				// send email with password of account created.
				// send the pass to the creator email ( not the invited user ( avoid spam ))
				let to = user.emails[0].address
				Email.send({
					to: to,
					from: process.env.MAIL_FROM,
					subject: 'New user account created & invited',
					text: 	
						'You have invited a new user: "'+userEmail+'", his account has been created for you.\n'+
						'Please give the your new collaborator his credentials: \n\n'+
						'Login: ' + userEmail+'\n'+
						'Password: ' + pass
				});
			}
		}
		return { hasCreateUser: hasCreateUser };
	},
开发者ID:djulls07,项目名称:projects-manager,代码行数:62,代码来源:projects.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript reactive-var.ReactiveVar类代码示例发布时间:2022-05-25
下一篇:
TypeScript mongo.Mongo.Collection类代码示例发布时间: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