Skip to content

Instantly share code, notes, and snippets.

@dubzzz
Created July 2, 2020 18:04
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 dubzzz/90eca0f675f0ea054ad16aec907219b7 to your computer and use it in GitHub Desktop.
Save dubzzz/90eca0f675f0ea054ad16aec907219b7 to your computer and use it in GitHub Desktop.
const map = (g, mapper, unmapper) => {
return {
generate(mrng) {
return mapper(g.generate(mrng));
},
*shrink(value) {
for (const shrunkValue of g.shrink(unmapper(value))) {
yield mapper(shrunkValue);
}
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment