var http = require('request-promise');
var _ = require('lodash');
var URL = "http://www.colr.org/json/scheme/random";
async function randomColorScheme() {
var response = await http(URL);
var scheme = JSON.parse(response)['schemes'][0];
try {
var colors = _.map(scheme['colors'], function(c) {return "#" + c});
var tags = _.map(scheme['tags'], function(t) {return t['name']});
return {colors: colors, tags: tags};
} catch (e) {
return {};
}
};
module.exports = randomColorScheme;