Change seeds so they work the first time they are passed in #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug Report
Currently the way randomColor works, a seed will work the very first time it's passed in, but if the seed changes, it uses the last seed that was passed in to generate the color(s), and then it sets the new seed, causing the wrong output.
Here's an example:
As you can see, when you run the generator with one seed (first run), change the seed, run it again (second run), it generates the wrong array of colors. Then when you run it for the third time (with the
same seed as the second run), it generates the correct array of colors.
Solution
This pull request modifies the behavior of the seed option so that the seed is reset at the end of each run.
I've also written a test that fails if you use the original version of randomColor (before my changes), so that you can run it (via
npm run test
) and easily see the bug.Misc
I've also bumped the version number in package.json, as well as added a version number to the bower.json file. I also created a new tag for the 0.4.1 release (not sure if this will move over when my PR is merged in though…)