function findNearestHistory()

in assets/ml-metrics.js [34:42]


function findNearestHistory(target, list) {
  if (!Array.isArray(list) || list.length === 0) {
    throw new Error("The list must be a non-empty array.");
  }

  return list.reduce((nearest, current) => {
    return Math.abs(current - target) < Math.abs(nearest - target) ? current : nearest;
  });
}