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

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

  const writeFile = function writeFile({
    filePath,
    options = {},
    _appendFile = (0, _rxjs.bindNodeCallback)(_fs.appendFile),
    _writeFile = (0, _rxjs.bindNodeCallback)(_fs.writeFile)
  }) {
    return fileChunk$ => fileChunk$.pipe((0, _operators.scan)(([index], chunk) => [index + 1, chunk], [-1, null]), (0, _operators.map)(([index, chunk]) => index === 0 ? _writeFile(filePath, chunk, options) : _appendFile(filePath, chunk, options)), (0, _operators.mergeAll)(1));
  };

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