Github標(biāo)星28.2k,可大批量生成假數(shù)據(jù),這個(gè)工具太牛
開源最前線(ID:OpenSourceTop) 猿妹整編 綜合自:https://medium.com/javascript-in-plain-english/faker-js-npm-module-for-generating-fake-data-5dae437ec3a



const?faker?=?require('faker');
let?firstName?=?faker.name.firstName();
let?lastName?=?faker.name.lastName();
console.log(`Employee:?${firstName}?${lastName}`);
名字
姓氏
職稱
工作領(lǐng)域
工作類型
......


??<script?src?=?"faker.js"?type?=?"text/javascript">script>
????<script>
??????var?randomName?=?faker.name.findName();?//?Caitlyn?Kerluke
??????var?randomEmail?=?faker.internet.email();?//[email protected]
??????var?randomCard?=?faker.helpers.createCard();?//?random?contact?card?containing?many?properties
????script>
?const?faker?=?require('faker');
let?phone?=?faker.phone.phoneNumber();
console.log(`Phone:?${phone}`);
console.log(`Vehicle:?${faker.vehicle.model()}?${faker.vehicle.type()}`)
console.log(`Credit?Card:?${faker.finance.creditCardNumber()}`)
faker.locale?=?"ru";
let?firstName?=?faker.name.firstName();
let?lastName?=?faker.name.lastName();
console.log(`Pаботник:?${firstName}?${lastName}`);
let?month?=?faker.date.month();
let?recentDate?=?faker.date.recent();
console.log(`Month?${month}?and?Date?${recentDate}?`)
faker.locale?=?"nl";
//?use?faker?moustache?expressions?as?placeholders?for?generated?data
const?fakePerson?=?{?"name"??????:"{{name.firstName}}?{{name.lastName}}"
,?"address"???:?{?"street"?:"{{address.streetName}}?{{random.number}}"
,?"city"???:"{{address.city}}"
,?"country":"{{address.country}}"
}
,?"birthdate"?:?"{{date.past}}"
}
//?feed?stringified?representation?of?JSON?object?to?faker.fake?to?replace?moustache?expressions?with?generated?data
const?person?=?JSON.parse(?faker.fake(?JSON.stringify(fakePerson)))
console.log(JSON.stringify(person))

最近熱文: 20套Java實(shí)戰(zhàn)項(xiàng)目視頻,涉及SpringBoot、SSM、SpringCloud等等! 雷軍1994年寫的像詩(shī)一樣的代碼,我今天把它運(yùn)行起來(lái)了! 臥槽!這 TM 才是真正的老司機(jī)看片神器!?。?/span> 臥槽!微信圖標(biāo)現(xiàn)在可以換顏色了?! 10款必裝軟件,讓W(xué)indows使用效率飛起! 對(duì)比27種語(yǔ)言,哪種編程語(yǔ)言又快又省電? 支付寶錢包系統(tǒng)架構(gòu)圖解,真的太優(yōu)秀了! LeetCode1-100題匯總,希望對(duì)你有點(diǎn)幫助! 2T技術(shù)資源大放送!包括但不限于:C/C++,Linux,Python,Java,人工智能,考研,軟考,英語(yǔ),等等。在公眾號(hào)內(nèi)回復(fù)「資源」,即可免費(fèi)獲?。?span style="letter-spacing: 0.544px;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);font-weight: bolder;">回復(fù)「社群」,可以邀請(qǐng)你加入讀者群! 更多好玩有趣的GitHub項(xiàng)目
評(píng)論
圖片
表情
