findDataPoint.ts 265 B

123456789
  1. export function findSampleFromDataPoint<T extends {timestamp: string}>(
  2. dataPoint: {name: string | number; value: number},
  3. data: T[],
  4. matchKey: keyof T
  5. ) {
  6. return data?.find(
  7. s => s.timestamp === dataPoint.name && s[matchKey] === dataPoint.value
  8. );
  9. }