main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
877 bytes
|
Line | |
---|
1 | import baseIteratee from './_baseIteratee.js';
|
---|
2 | import baseMean from './_baseMean.js';
|
---|
3 |
|
---|
4 | /**
|
---|
5 | * This method is like `_.mean` except that it accepts `iteratee` which is
|
---|
6 | * invoked for each element in `array` to generate the value to be averaged.
|
---|
7 | * The iteratee is invoked with one argument: (value).
|
---|
8 | *
|
---|
9 | * @static
|
---|
10 | * @memberOf _
|
---|
11 | * @since 4.7.0
|
---|
12 | * @category Math
|
---|
13 | * @param {Array} array The array to iterate over.
|
---|
14 | * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
---|
15 | * @returns {number} Returns the mean.
|
---|
16 | * @example
|
---|
17 | *
|
---|
18 | * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
|
---|
19 | *
|
---|
20 | * _.meanBy(objects, function(o) { return o.n; });
|
---|
21 | * // => 5
|
---|
22 | *
|
---|
23 | * // The `_.property` iteratee shorthand.
|
---|
24 | * _.meanBy(objects, 'n');
|
---|
25 | * // => 5
|
---|
26 | */
|
---|
27 | function meanBy(array, iteratee) {
|
---|
28 | return baseMean(array, baseIteratee(iteratee, 2));
|
---|
29 | }
|
---|
30 |
|
---|
31 | export default meanBy;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.