reduce<T> method

Future<T> reduce<T>(
  1. T fn(
    1. T accu,
    2. dynamic value,
    3. int index,
    4. ArangoCursor self
    ),
  2. T accu
)

Implementation

Future<T> reduce<T>(
  T Function(T accu, dynamic value, int index, ArangoCursor self) fn,
  T accu,
) async {
  var index = 0;
  while (_result.isNotEmpty || _hasMore) {
    while (_result.isNotEmpty) {
      accu = fn(accu, _result.removeAt(0), index, this);
      index++;
    }
    if (_hasMore) await _more();
  }
  return accu;
}