Tree.

mapReduce(tree, valueFn, reduceFn)

Maps and reduces a map-based tree to a single value. See also Tree.reduce.

  • The valueFn will be invoked to map individual leaf values in the tree. The signature of this function is (value, key, tree) (the same as for the value function in Tree.map.).
  • For each level of the tree, the reduceFn will be called with the mapped values. Its signature is (values, keys, tree). The result of this function is used as the result of reducing this branch of the tree.