本文整理汇总了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;
}
开发者ID:jbhg,项目名称:staffer,代码行数:30,代码来源:generate-data.ts
示例2: parseInt
_.each(projects, company => {
let id = nextId++;
projectMap[id] = {
id: id,
name: company,
location: chance.pick(locations),
companyId: parseInt(chance.pick(companyIds))
};
});
开发者ID:jbhg,项目名称:staffer,代码行数:9,代码来源:generate-data.ts
示例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;
}
开发者ID:jbhg,项目名称:staffer,代码行数:24,代码来源:generate-data.ts
注:本文中的chance.pick函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论