Skip to content

Instantly share code, notes, and snippets.

@garbles
Last active March 10, 2017 20:04
Show Gist options
  • Save garbles/ba5ded224c15b5f68c540e1434b68f78 to your computer and use it in GitHub Desktop.
Save garbles/ba5ded224c15b5f68c540e1434b68f78 to your computer and use it in GitHub Desktop.
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