Created
July 2, 2020 17:05
-
-
Save dubzzz/5ac4e85c22739d3c4d09a6e7c07aa871 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
| miniFc.tuple = (...itemGenerators) => { | |
| return { | |
| generate(mrng) { | |
| return itemGenerators.map(g => g.generate(mrng)); | |
| } | |
| }; | |
| } | |
| // It can be used as follow: | |
| // > miniFc.tuple(miniFc.integer(0, 50), miniFc.boolean()).generate(mrng) | |
| miniFc.array = (itemGenerator) => { | |
| return { | |
| generate(mrng) { | |
| const size = mrng.next(0, 10); | |
| const content = []; | |
| for (let index = 0 ; index !== size ; ++index) { | |
| content.push(itemGenerator.generate(mrng)); | |
| } | |
| return content; | |
| } | |
| }; | |
| } | |
| // It can be used as follow: | |
| // > miniFc.array(miniFc.character()).generate(mrng) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment