whychdw
2019-09-09 c0b9ce437d409b89ca0e5388344ca9c5a56d70a4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
 *
 *  (c) 2010-2019 Pawel Fus & Daniel Studencki
 *
 *  License: www.highcharts.com/license
 *
 *  !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
 *
 * */
'use strict';
 
Object.defineProperty(exports, "__esModule", {
    value: true
});
 
var _Globals = require('../parts/Globals.js');
 
var _Globals2 = _interopRequireDefault(_Globals);
 
require('../parts/Utilities.js');
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
var reduce = _Globals2.default.reduce;
var reduceArrayMixin = {
    /**
     * Get min value of array filled by OHLC data.
     * @privagte
     * @param {Array<Highcharts.OHLCPoint>} arr Array of OHLC points (arrays).
     * @param {string} index Index of "low" value in point array.
     * @return {number} Returns min value.
     */
    minInArray: function minInArray(arr, index) {
        return reduce(arr, function (min, target) {
            return Math.min(min, target[index]);
        }, Number.MAX_VALUE);
    },
    /**
     * Get max value of array filled by OHLC data.
     * @private
     * @param {Array<Highcharts.OHLCPoint>} arr Array of OHLC points (arrays).
     * @param {string} index Index of "high" value in point array.
     * @return {number} Returns max value.
     */
    maxInArray: function maxInArray(arr, index) {
        return reduce(arr, function (max, target) {
            return Math.max(max, target[index]);
        }, -Number.MAX_VALUE);
    },
    /**
     * Get extremes of array filled by OHLC data.
     * @private
     * @param {Array<Highcharts.OHLCPoint>} arr Array of OHLC points (arrays).
     * @param {string} minIndex Index of "low" value in point array.
     * @param {string} maxIndex Index of "high" value in point array.
     * @return {Array<number,number>} Returns array with min and max value.
     */
    getArrayExtremes: function getArrayExtremes(arr, minIndex, maxIndex) {
        return reduce(arr, function (prev, target) {
            return [Math.min(prev[0], target[minIndex]), Math.max(prev[1], target[maxIndex])];
        }, [Number.MAX_VALUE, -Number.MAX_VALUE]);
    }
};
exports.default = reduceArrayMixin;