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

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

  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

  const sliceBuffer = (buffer, cutoffLength) => index => {
    return buffer.slice(index * cutoffLength, (index + 1) * cutoffLength);
  };

  const shortenChunks = (cutoffLength = 512) => {
    return fileChunk$ => fileChunk$.pipe((0, _operators.mergeMap)(fileChunk => {
      const numChunks = Math.ceil(fileChunk.length / cutoffLength);

      const chunks = _lodash.default.times(numChunks).map(sliceBuffer(fileChunk, cutoffLength));

      return (0, _rxjs.of)(...chunks);
    }));
  };

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