Created
July 2, 2020 18:00
-
-
Save dubzzz/d581033b468b33950455f9f042a5919c to your computer and use it in GitHub Desktop.
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
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