本文整理汇总了TypeScript中faker.name.firstName方法的典型用法代码示例。如果您正苦于以下问题:TypeScript name.firstName方法的具体用法?TypeScript name.firstName怎么用?TypeScript name.firstName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类faker.name
的用法示例。
在下文中一共展示了name.firstName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getBaseName
function getBaseName(isMale: boolean): string {
const gender = getMaleNumber(isMale);
const random = faker.random.number(3);
switch (random) {
default: case 0: return faker.name.firstName(gender);
case 1: return faker.name.lastName(gender);
case 2:
const firstName = faker.name.firstName(gender);
const lastName = faker.name.lastName(gender);
const name = firstName + lastName;
return name.length > characterConfig.MAX_NAME_LENGTH ? firstName : name;
}
}
示例2: getRandomPerson
export function getRandomPerson(options: GetRandomPersonOptions) {
const opts: GetRandomPersonOptions = options || {};
opts.maxDateOfBirth = opts.maxDateOfBirth || new Date(Date.now() - MS_IN_YEAR);
opts.minAge = opts.minAge || 18;
opts.maxAge = opts.maxAge || 105;
opts.depth = opts.depth || 0;
// Generates a family tree...of sorts
const result: Person = {
name: faker.name.lastName() + faker.name.firstName(),
employment: {
companyName: faker.company.companyName()
},
regex: /a/g,
age: faker.random.number(),
dateOfBirth: faker.date.past(),
enrolledToVote: faker.random.boolean(),
};
if (opts.depth > 0) {
result.parents = [
getRandomPerson({ depth: opts.depth - 1 }),
getRandomPerson({ depth: opts.depth - 1 })
];
}
return result;
}
示例3: function
const getRandomPeople = function(count: number) : Person[] {
const people = [];
for (let ctr=0; ctr<count;ctr++) {
people.push({
name: faker.name.firstName(),
height: faker.random.number({min: 40, max: 88})
});
}
return people;
};
示例4:
const createMessage = (channelId) => {
return {
id: faker.random.uuid(),
content: faker.lorem.sentence(),
creationTime: faker.date.past().getTime().toString(),
author: {
name: faker.name.firstName() + '.' + faker.name.lastName(),
avatar: faker.image.avatar(),
},
channel: { id: channelId },
};
};
示例5: createFakeRowObjectData
createFakeRowObjectData(index: number): Object {
return {
id: index,
avartar: faker.image.avatar(),
city: faker.address.city(),
email: faker.internet.email(),
firstName: faker.name.firstName(),
lastName: faker.name.lastName(),
street: faker.address.streetName(),
zipCode: faker.address.zipCode(),
date: faker.date.past(),
bs: faker.company.bs(),
catchPhrase: faker.company.catchPhrase(),
companyName: faker.company.companyName(),
words: faker.lorem.words(),
sentence: faker.lorem.sentence(),
};
}
示例6: generatePeople
export function generatePeople(): Array<PersonModel> {
var personList: Array<PersonModel> = [];
for (var i = 0; i < NUM_PEOPLE; i++) {
var fname = faker.name.firstName(1);
var lname = faker.name.lastName(1);
var created = faker.date.recent(3).toDateString();
let p = new PersonModel();
p.firstname = fname;
p.lastname = lname;
p.CreatedAt = created;
Database.insert(p).then(id => {
console.log("insert success", id);
p.ID = id;
}, error => {
console.log("insert error", error);
});
personList.push(p);
}
return personList;
}
示例7: return
export const makeAuthor = (): AuthorModel => {
return (new AuthorModel())
.setFirstName(name.firstName())
.setLastName(name.lastName());
};
示例9: firstName
public static firstName() {
return faker.name.firstName();
}