constance
Version:
constants with prefix and postfix options
17 lines (13 loc) • 348 B
JavaScript
module.exports = function constance(prefix, keys, postfix) {
if(typeof prefix === 'object') {
postfix = keys;
keys = prefix;
prefix = '';
}
postfix = postfix || '';
if(!Array.isArray(keys)) keys = Object.keys(keys);
return keys.reduce(function(obj, key) {
obj[key] = prefix + key + postfix;
return obj;
}, {});
}