getExpandedMap = (dim, expandBy) => {
let indices = _.sortBy(_.uniq(dim));
let offsets = _.zip([-1, ...indices.slice(0, -1)], indices).map(
([prevIndex, index]) => index - (prevIndex + 1)
);
let offset = 0;
const expandedDim = [];
for (const [item, itemOffset] of _.zip(indices, offsets)) {
offset += itemOffset * (expandBy - 1);
expandedDim.push(item + offset);
}
return Object.fromEntries(_.zip(indices, expandedDim));
}