repl.txt (1320B)
1 2 {{alias}}( collection, [options,] indicator ) 3 Generates a frequency table according to an indicator function. 4 5 When invoked, the indicator function is provided two arguments: 6 7 - `value`: collection value 8 - `index`: collection index 9 10 The table is an array of arrays where each sub-array corresponds to a unique 11 value in the input collection. Each sub-array is structured as follows: 12 13 - 0: unique value 14 - 1: value count 15 - 2: frequency percentage 16 17 If provided an empty collection, the function returns an empty array. 18 19 Parameters 20 ---------- 21 collection: Array|TypedArray|Object 22 Input collection to tabulate. If provided an object, the object must be 23 array-like (excluding strings and functions). 24 25 options: Object (optional) 26 Options. 27 28 options.thisArg: any (optional) 29 Execution context. 30 31 indicator: Function 32 Indicator function specifying how to categorize a collection element. 33 34 Returns 35 ------- 36 out: Array<Array>|Array 37 Frequency table. 38 39 Examples 40 -------- 41 > function indicator( value ) { return value[ 0 ]; }; 42 > var collection = [ 'beep', 'boop', 'foo', 'beep' ]; 43 > var out = {{alias}}( collection, indicator ) 44 [ [ 'b', 3, 0.75 ], [ 'f', 1, 0.25 ] ] 45 46 See Also 47 -------- 48