This Gist was automatically created by Carbide, a free online programming environment.
Last active
October 5, 2017 22:27
-
-
Save billymoon/b603bf971112be2943b9160738b8ec0e to your computer and use it in GitHub Desktop.
untitled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(' '); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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