mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
621 B
32 lines
621 B
const _ = require('lodash');
|
|
|
|
function getFieldMask(obj) {
|
|
return _.keys(obj).join(',');
|
|
}
|
|
|
|
function columnToLetter(column) {
|
|
let temp;
|
|
let letter = '';
|
|
let col = column;
|
|
while (col > 0) {
|
|
temp = (col - 1) % 26;
|
|
letter = String.fromCharCode(temp + 65) + letter;
|
|
col = (col - temp - 1) / 26;
|
|
}
|
|
return letter;
|
|
}
|
|
|
|
function letterToColumn(letter) {
|
|
let column = 0;
|
|
const { length } = letter;
|
|
for (let i = 0; i < length; i++) {
|
|
column += (letter.charCodeAt(i) - 64) * 26 ** (length - i - 1);
|
|
}
|
|
return column;
|
|
}
|
|
|
|
module.exports = {
|
|
getFieldMask,
|
|
columnToLetter,
|
|
letterToColumn,
|
|
};
|
|
|