Skip to content

Instantly share code, notes, and snippets.

@billymoon
Last active October 5, 2017 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billymoon/b603bf971112be2943b9160738b8ec0e to your computer and use it in GitHub Desktop.
Save billymoon/b603bf971112be2943b9160738b8ec0e to your computer and use it in GitHub Desktop.
untitled
import fiona from 'fiona'
import './lorem'
import './nino'
const seeded = fiona()
seeded.lorem()
seeded.sentence()
seeded.para()
// seeded.data(({ seeded }) => ({
// fullname: ({ seeded }) => seeded.name(),
// nino: ({ seeded }) => seeded.nino()
// }))
// seeded.data(({ seeded }) => ({
// age: seeded.number(100)
// }))
// seeded.data()
import fiona from 'fiona'
fiona.fn.lorem = function (qty = 15) {
let out = this.random() < 0.2 ? 'lorem ipsum ' : '';
let words = []
while (words.length < qty) {
words = words.concat('dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum'.split(' '));
}
let min = Math.ceil(qty - qty / 3);
let max = Math.ceil(qty + qty / 3) - 2;
return out + this.choose(this.number(max, min), words).join(' ');
}
fiona.fn.sentence = function () {
let para = this.lorem(25);
return para[0].toUpperCase() + para.slice(1) + '.';
};
fiona.fn.para = function () {
return Array(this.number(10, 1)).fill(0).map(i => this.sentence()).join(' ');
};
import fiona from 'fiona'
fiona.fn.nino = function () {
return this.regex(/[A-Z]{2}\d{6}[A-Z]/)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment