本文整理汇总了TypeScript中chance.pick函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pick函数的具体用法?TypeScript pick怎么用?TypeScript pick使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pick函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: generateNeeds
function generateNeeds(): any {
let skillIds = Object.keys(store.skillMap);
let projectIds = Object.keys(store.projectMap);
let needMap: any = {};
for (let i = 0; i < 50; i++) {
let id = nextId++;
// Set start date to Monday this week + random number of weeks
var numWeeksAfter = chance.integer({ min: 0, max: 26 });
var startDate = moment().weekday(1).startOf('day').add(numWeeksAfter, 'weeks');
// Set duration to a random number of weeks
var numWeeksDuration = chance.integer({ min: 1, max: 26 });
var endDate = startDate.clone().add(numWeeksDuration - 1, 'weeks').add(4, 'days').endOf('day');
needMap[id] = {
id: id,
startDate: startDate.toDate(),
endDate: endDate.toDate(),
projectId: parseInt(chance.pick(projectIds)),
skillId: parseInt(chance.pick(skillIds)),
personId: null,
};
};
return needMap;
}
示例2: parseInt
_.each(projects, company => {
let id = nextId++;
projectMap[id] = {
id: id,
name: company,
location: chance.pick(locations),
companyId: parseInt(chance.pick(companyIds))
};
});
示例3: generatePeople
function generatePeople(): any {
let skillIds = Object.keys(store.skillMap);
let personMap: any = {};
for (let i = 0; i < 50; i++) {
let id = nextId++;
personMap[id] = {
id: id,
name: chance.name(),
email: chance.email(),
phone: chance.phone(),
skillIds: [
parseInt(chance.pick(skillIds)),
parseInt(chance.pick(skillIds))
],
needIds: [
]
};
};
return personMap;
}