开源软件名称(OpenSource Name):icebob/fakerator开源软件地址(OpenSource Url):https://github.com/icebob/fakerator开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):fakerator
fakerator was inspired by and has used data definitions from Marak's faker.js library If you like my work, please donate. Thank you! DemoInstallBower$ bower install fakerator NodeJS$ npm install fakerator ManualDownload the package and use the UsageBrowser<script src="https://rawgit.com/icebob/fakerator/master/dist/fakerator.js"></script>
<script>
var fakerator = Fakerator();
var name = fakerator.names.name();
var user = fakerator.entity.user();
</script> NodeJSvar Fakerator = require("fakerator");
var fakerator = Fakerator("de-DE");
var name = fakerator.names.name();
// Result: 'Dr. Marcus Drechsler' Shortly var fakerator = require("fakerator")("hu-HU");
var name = fakerator.names.name();
// Result: 'Fülöp Magdolna' Or load a specific locale var fakerator = require("fakerator/locales/de-DE")();
var name = fakerator.names.name();
// Result: 'Dr. Marcus Drechsler' SeedingThe library uses the Mersenne Twister pseudorandom number generator, so set seed value, if you want to get a repeatable random sequence: fakerator.seed(5567832); RandomGenerate random values or select a random element from array.
LocalizationThe library supports localizations. You can set the locale code in constructor. Usage // Use default (English) localization
var fakerator = Fakerator();
console.log(fakerator.names.name());
// Floyd Corkery // Use german
var fakerator = Fakerator("de-DE");
console.log(fakerator.names.name());
// Hassan vom Kumbernuss // Use russian
var fakerator = Fakerator("ru-RU");
console.log(fakerator.names.name());
// Альберт Валентинович Архипов In production, you can load only a specific locale: // Use french
var fakeratorFR = require("fakerator/locales/fr-FR")();
console.log(fakeratorFR.names.name());
// Dufour Camille Available localizations:
Custom localePlease read this how to add a new locale GeneratorsUse this functions to generate fake random data Names
Address
Phone
Company
Internet data
Lorem
Date & time
Miscellaneous
EntitiesYou can generate complex entities Userfakerator.entity.user() Result: {
"firstName": "Ashley",
"lastName": "Kautzer",
"userName": "ashley38",
"password": "yuzasimima",
"email": "ashleykautzer74@hotmail.com",
"phone": "1-485-841-6009",
"dob": "1939-11-22T01:15:16.735Z",
"website": "http://natalie-walker.info",
"ip": "202.26.104.4",
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/jakemoore/128.jpg",
"gravatar": "https://www.gravatar.com/avatar/7875d665c96e5e388aa4074697cab0a0",
"address": {
"country": "Northern Mariana Islands",
"countryCode": "MP",
"state": "Michigan",
"city": "New Jamie",
"street": "1730 Abbott Views Apt. 460",
"zip": "77988",
"geo": {
"latitude": -41.5878,
"longitude": 34.266400000000004
}
},
"status": false
} You can set genre of user with first parameter. // F - female, M - male
fakerator.entity.user("F"); Addressfakerator.entity.address() Result: {
"country": "Bulgaria",
"countryCode": "BG",
"state": "Indiana",
"city": "North Michele",
"street": "06169 Beer Villages Suite 302",
"zip": "20896",
"geo": {
"latitude": -9.275499999999994,
"longitude": 92.53280000000001
}
} Companyfakerator.entity.company() Result: {
"name": "Cormier, Murphy and Turcotte Ltd.",
"email": "cormier-murphy-and-turcotte-ltd.90@hotmail.com",
"phone": "044.708.8876 x834",
"website": "https://olgabeatty.info",
"ip": "54.65.201.35",
"address": {
"country": "Caribbean Netherlands",
"countryCode": "BQ",
"state": "Kansas",
"city": "East Ronnie",
"street": "81019 Cormier Mall",
"zip": "11474-0882",
"geo": {
"latitude": 1.6444000000000045,
"longitude": 107.97910000000002
}
}
} Blog postfakerator.entity.post() Result: {
"title": "Esse excepturi eum id ab aut dolore veritatis et.",
"keywords": [
"commodi",
"odio",
"sit"
],
"created": "2016-05-25T18:19:46.283Z",
"content": "Mollitia officiis quam nulla veritatis omnis eius enim quis. Dolorem est reiciendis adipisci. Laboriosam enim saepe sunt nisi. Autem tempora ullam non laborum. Qui dolorem fugiat amet. Eius consectetur ea et minus ipsam et qui unde doloremque.\r\nNihil minima aut. Voluptatibus neque at nulla ut expedita laboriosam. Veniam natus voluptates nulla voluptas impedit cumque qui nihil.\r\nMinus quos in autem facere dolorem quidem rem rerum. Animi quo eaque debitis nam non earum molestiae. Maxime vitae exercitationem doloremque."
} TimesYou can generate array of items with
Usage// Generate 3 names
fakerator.times(fakerator.names.name, 3);
// [ "Ross Hansen", "Thomas Pfeffer", "Alexis Hauck I" ]
// Generate 5 username with populate where first name must be 'John'
fakerator.times(fakerator.populate, 5, "#{internet.userName}", "John");
// [ 'john.langosh8341', 'john12', 'john.howe5075', 'john_jerde', 'john.grant9923' ]
// Generate 5 number from 1 to 10
fakerator.times(fakerator.random.number, 5, 1, 10);
// [ 10, 8, 1, 8, 5 ]
// Note: 8 is twice!
// Generator 5 UNIQUE number from 1 to 10
fakerator.utimes(fakerator.random.number, 5, 1, 10);
// [ 10, 2, 9, 6, 1 ]
// Note: every number is unique! TemplatesYou can also generate fake data with templates: fakerator.populate("#{names.name}")
// Ross Hansen fakerator.populate("#{address.street}")
// 0662 Ferry Drive 全部评论
专题导读
上一篇:OCA/l10n-ecuador: Odoo Localization for Ecuador发布时间:2022-08-16下一篇:OCA/l10n-morocco: Moroccan Localization发布时间:2022-08-16热门推荐
热门话题
阅读排行榜
|
请发表评论