UNPKG

newmax-utils

Version:
21 lines (20 loc) 591 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.renameObjKey = void 0; const renameObjKey = (row) => { const newData = {}; Object.keys(row).forEach((key, index) => { const columnLetter = getColumnLetter(index); newData[columnLetter] = row[key]; }); return newData; }; exports.renameObjKey = renameObjKey; function getColumnLetter(index) { let letter = ''; while (index >= 0) { letter = String.fromCharCode((index % 26) + 65) + letter; index = Math.floor(index / 26) - 1; } return letter; }