本文整理汇总了TypeScript中faker.name类的典型用法代码示例。如果您正苦于以下问题:TypeScript name类的具体用法?TypeScript name怎么用?TypeScript name使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了name类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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;
}
示例2: times
data: times(3, (index) => {
return {
'id' : index + +offset + 1,
'firstname': faker.name.findName().split(' ')[0],
'lastname': faker.name.findName().split(' ')[0],
'email': faker.internet.email()
};
})
示例3:
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 },
};
};
示例4: 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;
}
}
示例5: createItem
function createItem() {
return {
name: faker.name.findName(),
phone: faker.phone.phoneNumber(),
country: faker.address.country()
};
}
示例6: 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(),
};
}
示例7: createArray
const persons = createArray(numberOfPersons, i => {
return [
i,
faker.name.findName(),
faker.address.streetAddress(),
faker.phone.phoneNumber(),
faker.date.past(),
]
})
示例8: 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;
};
示例9: 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;
}
示例10: switch
function getSanitizedValue<D>(
defaultValue: D,
sanitizeConfig?: SanitizeConfig
) {
if (!sanitizeConfig) return defaultValue;
switch (sanitizeConfig) {
case 'name':
return faker.name.findName();
case 'email':
return faker.internet.email();
case 'lorem':
return faker.lorem.sentences();
default:
return faker.lorem.text();
}
}