cartodb/lib/assets/javascripts/builder/data/layer-letters.js

24 lines
473 B
JavaScript
Raw Normal View History

2020-06-15 10:58:47 +08:00
var _ = require('underscore');
module.exports = {
/**
* Get the next available letter.
* @param {Array} letters e.g. ['a', 'b', 'd']
* @return {String} e.g. 'c'
*/
next: function (letters) {
return _.chain(letters)
.sort()
.reduce(function (memo, letter) {
if (letter === memo) {
return String.fromCharCode(letter.charCodeAt() + 1);
} else {
return memo;
}
}, 'a')
.value();
}
};