colors.js/lib/maps/rainbow.js
Marak dfb15b5538 [refactor] [major] Code cleanup. Node has changed a bit since 2010.
[api] Added ability to safely require colors without messing with String.prototype
[api] Removed browser functionality
[dist] Add travis file
2014-09-30 22:41:24 +02:00

14 lines
344 B
JavaScript

var colors = require('../colors');
module['exports'] = (function () {
var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; //RoY G BiV
return function (letter, i, exploded) {
if (letter === " ") {
return letter;
} else {
return colors[rainbowColors[i++ % rainbowColors.length]](letter);
}
};
})();