Last active
March 10, 2017 20:04
-
-
Save garbles/ba5ded224c15b5f68c540e1434b68f78 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 {sample, sampleOne} from 'babel-plugin-transform-flow-to-gen/api'; | |
type Person = { | |
name: string, | |
age: number | |
} | |
// creates a generator | |
const personGen = Person(); | |
// creates a sample of that type | |
const person = sampleOne(personGen); | |
console.log(person); | |
// { "name": "egd3z", "age": 2 } | |
// creates 200 samples | |
const persons = sample(personGen, 200); | |
console.log(persons); | |
// [{ "name": "gf4E", "age": 0 }, { "name": "a", "age": 1 }, ... ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment