AugurProject/augur-ui

View on GitHub
src/modules/markets/helpers/find-period-series-bounds.js

Summary

Maintainability
A
0 mins
Test Coverage
import { compose, defaultTo, map, max, min, toString } from "lodash/fp";

const getMinFn = marketMin =>
  compose(
    toString,
    defaultTo(marketMin),
    min,
    map("low")
  );

const getMaxFn = marketMax =>
  compose(
    toString,
    defaultTo(marketMax),
    max,
    map("high")
  );

export default function findPeriodSeriesBounds(
  periodTimeSeries = [],
  marketMin = 0,
  marketMax = 1
) {
  return {
    min: getMinFn(marketMin)(periodTimeSeries),
    max: getMaxFn(marketMax)(periodTimeSeries)
  };
}