davidmerfield/randomColor — pull request #6 by bilalq (2014-06-01 03:53:16+00:00)
Title: Expose module through the UMD format

This change allows this module to be consumed by a variety of different module loaders, as well as bring in some performance optimizations.

* If either Node or Component are the environment its running in, it will expose itself via `module.exports`.
* If an AMD loader is present, it will register itself as an AMD module.
* In the event that no such system is present, it will simply expose a global called `randomColor` (the same as it used to always do).

The diff of the first commit makes its change seem bigger than than they are. Basically, the entirety of the old codebase is now wrapped in a factory function that returns the `randomColor` function. This causes everything to be indented over one, and that's why it looks like a massive change.

The second commit does some optimizations that work everywhere as well. Before, all the helper functions would be redefined each time `randomColor` was invoked. Now, the factory function returns `randomColor` as a closure that maintains a reference to all its helpers.