Maybe a different organization:
const transformedSortFunc = (sortingPath) => {
if (!sortingPath) return sortingPath;
const negative = sortingPath[0] === '-' ? '-' : '';
const sortingValue = negative ? sortingPath.slice(1) : sortingPath;
const transformPath = get(SORTING_PATH_MAP, sortingValue);
return transformPath ? `${negative}${transformPath}` : sortingPath;
};
CLICK HERE to find out more related problems solutions.