Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

compute-io / argmax / 9

9 Jun 2015 - 5:16 coverage: 97.059% (-2.9%) from 100.0%
9

Pull #1

travis-ci

88cba5f6ee044b057480fe2cff63825b?size=18&default=identiconkgryte
[UPDATE] dependencies
Pull Request #1: Update according to TODO

98 of 101 new or added lines in 5 files covered. (97.03%)

99 of 102 relevant lines covered (97.06%)

36.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.75
/lib/array.js
1
'use strict';
2

3
/**
4
* FUNCTION: argmax( arr )
5
*        Computes the maximum value of an array and returns the corresponding array indices.
6
*
7
* @param {Number[]|Int8Array|Uint8Array|Uint8ClampedArray|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array} arr - input array
8
* @returns {Number[]|Null} maximum value indices
9
*/
10
function argmax( arr ) {
3×
11
        var len = arr.length,
18×
12
                max,
13
                i, v,
14
                idx;
15

16
        if ( !len ) {
18×
17
                return null;
3×
18
        }
19
        max = arr[ 0 ];
15×
20
        idx = [ 0 ];
15×
21
        for ( i = 1; i < len; i++ ) {
15×
22
                v = arr[ i ];
75×
23
                if ( v > max ) {
75×
24
                        max = v;
45×
25
                        idx.length = 0;
45×
26
                        idx.push( i );
45×
27
                }
28
                else if ( v === max ) {
30×
NEW
29
                        idx.push( i );
!
30
                }
31
        }
32
        return idx;
15×
33
} // end FUNCTION argmax()
34

35

36
// EXPORTS //
37

38
module.exports = argmax;
3×
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2023 Coveralls, Inc