function mathValuesSelective (math, shouldApplyFn) {
  return function _mathSomeSelective (metricInstances) {
    return metricInstances.map(mi => {
      let result = shouldApplyFn(mi)
        ? { ...mi, data: mi.data.map(({ ts, value }) => ({ ts, value: math(value) })) }
        : mi
      return result
    })
  }
}
Perform generic (typically linear) math on instantaneous values

@param {function} math the function that will be executed on all values
@param {function} shouldApplyFn the function that decides whether the transform will apply
@return {function} a transform function