-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathgetReduceDeep.js
More file actions
27 lines (23 loc) · 631 Bytes
/
getReduceDeep.js
File metadata and controls
27 lines (23 loc) · 631 Bytes
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
'use strict';
var getEachDeep = require('./getEachDeep.js');
function getReduceDeep(_) {
var eachDeep = getEachDeep(_);
function reduceDeep(obj, iteratee, accumulator, options) {
var accumulatorInited = accumulator !== undefined;
eachDeep(
obj,
function (value, key, parent, context) {
if (!accumulatorInited) {
accumulator = value;
accumulatorInited = true;
} else {
accumulator = iteratee(accumulator, value, key, parent, context);
}
},
options
);
return accumulator;
}
return reduceDeep;
}
module.exports = getReduceDeep;