Skip to content

Instantly share code, notes, and snippets.

@dubzzz
Created July 2, 2020 18:00
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/d581033b468b33950455f9f042a5919c to your computer and use it in GitHub Desktop.
Save dubzzz/d581033b468b33950455f9f042a5919c to your computer and use it in GitHub Desktop.
miniFc.integer = (min, max) => {
return {
generate(mrng) {
return mrng.next(min, max);
},
*shrink(value) {
while (value !== min) {
value = min + Math.floor((value - min) / 2);
yield value;
}
}
}
}
// You can check the output by calling:
// > [...miniFc.integer(0, 100).shrink(64)]
// > [...miniFc.integer(0, 100).shrink(48)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment