function combineValuesAtTimestampReducer(combiner) {
  return (acc, dp) => {
    const existingIndex = acc.findIndex(e => e.ts.getTime() === dp.ts.getTime())
    // not found in array
    if (existingIndex === -1) {
      return acc.concat(dp)
    }

    // found in array, clone the array but replace the element
    const newArray = acc.slice()
    newArray[existingIndex] = {
      ts: acc[existingIndex].ts,
      value: combiner(acc[existingIndex].value, dp.value),
    }
    return newArray
  }
}
Given an array of { ts, value } tuples, combine them so that there is only
one ts value, using combine function