(function (global, factory) {
  if (typeof define === "function" && define.amd) {
    define(["exports", "rxjs/operators"], factory);
  } else if (typeof exports !== "undefined") {
    factory(exports, require("rxjs/operators"));
  } else {
    var mod = {
      exports: {}
    };
    factory(mod.exports, global.operators);
    global.mean = mod.exports;
  }
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _operators) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;

  const reducer = function reducer({
    sum,
    index
  }, nextNum) {
    return {
      average: (sum + nextNum) / (index + 1),
      sum: sum + nextNum,
      index: index + 1
    };
  };

  const mean = function mean(initialState = {
    average: null,
    sum: 0,
    index: 0
  }) {
    return source$ => source$.pipe((0, _operators.scan)(reducer, initialState), (0, _operators.map)(({
      average
    }) => average));
  };

  var _default = mean;
  _exports.default = _default;
});
//# sourceMappingURL=mean.js.map