invert a lookup table

Is there a function to invert a lookup table from vtk (vtk.js) ?

This is a button to do that from paraview:
image

var colorMap = $("#selectColorMap").val();
var lookup = vtk.Rendering.Core.vtkColorTransferFunction.newInstance();
var preset = vtk.Rendering.Core.vtkColorTransferFunction.vtkColorMaps.getPresetByName(colorMap);

var table = preset.RGBPoints;
var tableInvert = [];
for (var i = table.length/4-1; i >= 0;  i--) {
     tableInvert.push(-1*table[i*4], table[i*4+1], table[i*4+2], table[i*4+3]);
}
preset.RGBPoints = tableInvert;

lookup.applyColorMap(preset);
lookup.setNanColor(1.0, 1.0, 1.0, 1.0);
lookup.build();

will do it.
Is there a better way ?