本文整理汇总了TypeScript中lodash.sample函数的典型用法代码示例。如果您正苦于以下问题:TypeScript sample函数的具体用法?TypeScript sample怎么用?TypeScript sample使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sample函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: RandomUsers
static RandomUsers(count:number): User[]{
let users:User[]=[];
for(let i=0;i<count; i++){
users.push(new User(i, _.sample(FIRST_NAMES), _.sample(LAST_NAMES)));
}
return users;
}
开发者ID:Jaroost,项目名称:builder_app,代码行数:7,代码来源:user.ts
示例2: parseInt
const addUsers = (count, knex, date) => {
count = parseInt(count)
const rows = []
for (let i = 0; i < count; i++) {
const channel = _.sample(channels)
const id = _.uniqueId()
const first_name = { key: 'first_name', value: generateName(), type: 'string' }
const last_name = { key: 'last_name', value: generateName(), type: 'string' }
const gender = { key: 'gender', value: Math.random() < vary(0.65, 0.35) ? 'male' : 'female', type: 'string' }
const locale = { key: 'locale', value: _.sample(['en_US', 'fr_CA', 'en_CA']), type: 'string' }
const timezone = { key: 'timezone', value: _.random(-6, 12, false), type: 'string' }
const user = {
user_id: id,
channel: channel,
attributes: JSON.stringify([first_name, last_name, gender, locale, timezone]),
created_at: date
}
users.push(user)
rows.push(user)
}
return knex.batchInsert('srv_channel_users', rows, 20).then(() => console.log('Added', count, 'users'))
}
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:27,代码来源:seed.ts
示例3: times
return times(4, () => {
const device = sample (devices);
const location = sample(locations);
return {
device: device,
location: location,
name : sample(['Cloud', 'Lamp', 'Bridge']),
pin: sample(device.pins)
};
});
开发者ID:syafiqrokman,项目名称:angular5-iot-dashboard,代码行数:10,代码来源:mocks.service.ts
示例4: sample
const CONTACTS = COLORS.map((color, index) => {
const title = `${sample(['Mr.', 'Mrs.', 'Ms.', 'Unknown'])} ${color} 🔥`;
const key = sample(['name', 'profileName']) as string;
const id = `+1202555${padStart(index.toString(), 4, '0')}`;
const contact = {
color,
[key]: title,
id,
type: 'private',
};
return parent.ConversationController.dangerouslyCreateAndAdd(contact);
});
开发者ID:VetoPlayer,项目名称:Signal-Desktop,代码行数:14,代码来源:StyleGuideUtil.ts
示例5: enterScored
function enterScored(state: State) {
const goalText = sample(goalWords);
return state
.setIn(['round', 'scored'], true)
.setIn(['round', 'goalText'], goalText);
}
开发者ID:thomasboyt,项目名称:manygolf,代码行数:7,代码来源:reducer.ts
示例6: enabler
"!typegame": enabler((command: Tennu.Command) => {
var cache = typegameCache[command.channel] = typegameCache[command.channel] || { running: false };
if (typegameCache[command.channel].running) {
return util.format("A game is still running! Name %s Pokémon with the type %s!", cache.cnt, cache.types.join("/"));
} else {
(runningCache[command.channel] = runningCache[command.channel] || []).push("typegame")
var {type, cnt} = _.sample(Data.type_count_array);
console.log(cnt);
cache = typegameCache[command.channel] = {
running: true,
type: type,
cnt: _.random(1, _.min([5, cnt])),
max: cnt,
userCount: {},
guessed: {},
types: []
};
for (var i = 0; type; type >>= 1, ++i) {
if (type&1)
cache.types.push(Data.type_list[i]);
}
return util.format("Name %s Pokémon with the type %s!",
cache.cnt, cache.types.join("/")
);
}
}),
开发者ID:Cu3PO42,项目名称:CuBoid,代码行数:26,代码来源:typegame.ts
示例7: getRandomKiller
async getRandomKiller(): Promise<TKiller> {
const killers = (await this.fetch()).killers;
const killer = _.sample( killers.abilities );
return _.extend({}, killer, {
addons: _.sampleSize( killers.addons[ killer.name.replace(/The\s/, '') ], 2 )
});
}
开发者ID:solarflare045,项目名称:ultimate-bravery,代码行数:7,代码来源:randomizer.service.ts
示例8: constructor
constructor(private readonly log: Logger, private readonly options: BasePathProxyServerOptions) {
const ONE_GIGABYTE = 1024 * 1024 * 1024;
options.httpConfig.maxPayload = new ByteSizeValue(ONE_GIGABYTE);
if (!options.httpConfig.basePath) {
options.httpConfig.basePath = `/${sample(alphabet, 3).join('')}`;
}
}
开发者ID:Jaaess,项目名称:kibana,代码行数:8,代码来源:base_path_proxy_server.ts
示例9:
.then(pool => {
if (pool.length === 0) return null;
if (this.preferredTaskType) {
const task = _.find(pool, t => t.templateType === this.preferredTaskType);
if (task) return task;
}
return _.sample(pool);
});
开发者ID:CMUBigLab,项目名称:cmuNodeFbot,代码行数:8,代码来源:volunteer.ts
示例10: updateNextDirection
updateNextDirection() {
let allDirections = [Phaser.LEFT, Phaser.RIGHT, Phaser.UP, Phaser.DOWN];
let possibleDirections = _.filter(allDirections, (direction) => {
return direction !== this.currentDirection && direction !== this.opposites[this.currentDirection];
});
this.nextDirection = _.sample(possibleDirections);
return this.nextDirection;
}
开发者ID:DanEEStar,项目名称:ld35_shapman,代码行数:8,代码来源:main.ts
注:本文中的lodash.sample函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论