text: import { concat, Observable } from 'rxjs';
  import { last } from 'rxjs/operators';
  export function reduce(func, init = 0) {
      return line => new Promise((resolve, reject) => {
          line.collect(res => {
              let total = init;
              concat(...res.map(i => Observable.create((observer) => {
                  let _t = func(total, i);
                  const _complete = (t) => { total = t; observer.complete(); };
                  if (_t instanceof Observable)
                      _t.pipe(last()).subscribe(_complete);
                  else if (_t instanceof Promise)
                      _t.then(_complete);
                  else
                      _complete(_t);
              }))).subscribe(undefined, err => reject(err), () => resolve(total));
          });
      });
  }
  //# sourceMappingURL=reduce.js.map