packages/data-point/lib/reducer-types/resolve.js
function resolveReducer (manager, accumulator, reducer) {
  // this conditional is here because BaseEntity#resolve
  // does not check that lifecycle methods are defined
  // before trying to resolve them
  if (!reducer) {
    return Promise.resolve(accumulator)
  }

  const isTracing = accumulator.trace

  const acc = isTracing
    ? trace.augmentAccumulatorTrace(accumulator, reducer)
    : accumulator

  const traceNode = acc.traceNode

  const resolve = getResolveFunction(reducer)

  // NOTE: recursive call
  let result = resolve(manager, resolveReducer, acc, reducer)

  if (hasDefault(reducer)) {
    const _default = reducer[DEFAULT_VALUE].value
    const resolveDefault = reducers.ReducerDefault.resolve
    result = result.then(acc => resolveDefault(acc, _default))
  }

  if (isTracing) {
    result = result.then(trace.augmentTraceNodeDuration(traceNode))
  }

  return result
}
function resolveReducer (manager, accumulator, reducer) {
  // this conditional is here because BaseEntity#resolve
  // does not check that lifecycle methods are defined
  // before trying to resolve them
  if (!reducer) {
    return Promise.resolve(accumulator)
  }

  const isTracing = accumulator.trace

  const acc = isTracing
    ? trace.augmentAccumulatorTrace(accumulator, reducer)
    : accumulator

  const traceNode = acc.traceNode

  const resolve = getResolveFunction(reducer)

  // NOTE: recursive call
  let result = resolve(manager, resolveReducer, acc, reducer)

  if (hasDefault(reducer)) {
    const _default = reducer[DEFAULT_VALUE].value
    const resolveDefault = reducers.ReducerDefault.resolve
    result = result.then(acc => resolveDefault(acc, _default))
  }

  if (isTracing) {
    result = result.then(trace.augmentTraceNodeDuration(traceNode))
  }

  return result
}
function resolveReducer ( manager , accumulator , reducer ) { // this conditional is here because BaseEntity#resolve // does not check that lifecycle methods are defined // before trying to resolve them if ( ! reducer ) { return Promise . resolve ( accumulator ) } const isTracing = accumulator . trace const acc = isTracing ? trace . augmentAccumulatorTrace ( accumulator , reducer ) : accumulator const traceNode = acc . traceNode const resolve = getResolveFunction ( reducer ) // NOTE: recursive call let result = resolve ( manager , resolveReducer , acc , reducer ) if ( hasDefault ( reducer ) ) { const _default = reducer [ DEFAULT_VALUE ] . value const resolveDefault = reducers . ReducerDefault . resolve result = result . then ( acc => resolveDefault ( acc , _default ) ) } if ( isTracing ) { result = result . then ( trace . augmentTraceNodeDuration ( traceNode ) ) } return result }
Applies a Reducer to an accumulator

If Accumulator.trace is true it will execute tracing actions

@param {Object} manager
@param {Accumulator} accumulator
@param {Reducer} reducer
@returns {Promise<Accumulator>}
Applies a Reducer to an accumulator