diff --git a/package-lock.json b/package-lock.json index e35a3444a..e328c3a13 100644 --- a/package-lock.json +++ b/package-lock.json @@ -376,6 +376,11 @@ "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", "dev": true }, + "@types/lodash": { + "version": "4.14.150", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.150.tgz", + "integrity": "sha512-kMNLM5JBcasgYscD9x/Gvr6lTAv2NVgsKtet/hm93qMyf/D1pt+7jeEZklKJKxMVmXjxbRVQQGfqDSfipYCO6w==" + }, "@types/node": { "version": "7.0.13", "resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.13.tgz", @@ -12122,8 +12127,7 @@ "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", - "dev": true + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, "lodash._reinterpolate": { "version": "3.0.0", diff --git a/package.json b/package.json index 7e96e191e..026e3bcb9 100644 --- a/package.json +++ b/package.json @@ -49,12 +49,14 @@ "dependencies": { "@types/classnames": "^2.2.0", "@types/cookie": "^0.3.1", + "@types/lodash": "^4.14.150", "@types/random-seed": "^0.3.2", "@types/react": ">= 15", "@types/react-dom": ">= 15", "@types/react-transition-group": "^1.1.4", "classnames": "^2.2.5", "cookie": "^0.3.1", + "lodash": "^4.17.15", "normalize.css": "^8.0.1", "random-seed": "^0.3.0", "react": ">= 15", diff --git a/src/ts/utils/slider.ts b/src/ts/utils/slider.ts index 15ef8c559..559344518 100644 --- a/src/ts/utils/slider.ts +++ b/src/ts/utils/slider.ts @@ -1,3 +1,5 @@ +import { range } from 'lodash'; + export const getNumberOfSteps = (step: number, min: number, max: number) => { const totalRange = Math.abs(max - min); return Math.floor(totalRange / step) + 1; @@ -9,7 +11,9 @@ export const getStepSeries = ( max: number ): ReadonlyArray => { const stepCount = getNumberOfSteps(step, min, max); - const series = [...Array(stepCount)].map((_value: number, index: number) => min + index * step); + const series = range(stepCount).map( + (_VALUE: number, index: number) => min + index * step + ); // NOTE: if the last value in the series is less than the max we need another step in order to be able to select it return series[series.length - 1] < max ? [...series, max] : series; };