shamjs
Version:
Mock data generator.
45 lines (43 loc) • 1.43 kB
JavaScript
var jsonFormat = require('json-format')
var sham = require('../')
var r = sham.r
var fs = require('fs')
var moment = require('moment')
// IMPORTANT: // START
var data = sham.g(10, function () {
return {
integer: r.integer(),
integerRange: r.integer(10, 100),
pick: r.pick(['man', 'woman']),
pickString: r.pick('@!#$%^&*'),
pickSome: r.pick(['1','2','3','4','5', '6', '7', '8', '9'], 2),
pickSomeString: r.pick('@!#$%^&*', 3),
word: r.word(),
wordCount: r.word(2),
wordRange: r.word(5, 7),
cword: r.cword(),
// cword like word
id: r.id(),
color: r.color(),
bool: r.bool(),
// 30% return true
boolPercentage: r.bool(30),
domain: r.domain(),
name: r.name(),
nameFull: r.name(true),
cname: r.cname(),
email: r.email(),
time: r.time(),
timeRange: r.time(1492761899856, 1492762899856),
yyyymmdd: moment(r.time()).format('YYYY-MM-DD'),
yyyymmddRange: moment(r.time(1492761899856, 1492762899856)).format('YYYY-MM-DD'),
// Beautiful photo javaScript generator https://unsplash.it/
uh: r.uh(200),
uhWidthHeight: r.uh(200, 300),
uhWidthHeightRandom: r.uh(200, 300, 'r')
}
})
// IMPORTANT: // END
var json = jsonFormat(data)
var filepath = __dirname + '/list.json'
fs.writeFileSync(filepath, json)