{"version":3,"sources":["jsdelivr-header.js","/npm/keep-reading@1.1.0/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,IAAI,GAAK,QAAQ,MACb,IAAM,QAAQ,iBACd,SAAW,QAAQ,YACnB,MAAQ,QAAQ,SAKpB,SAAS,YAAa,EAAM,GAC1B,IAEI,EACA,EAHA,EAAU,IAAI,MAAM,CAAC,IAAK,IAAK,IAAK,MACpC,GAAS,EAIb,GAAS,IAAU,EAEnB,IAAI,EAAI,SAAS,KAAI,SAAU,EAAO,EAAK,GACzC,EAAM,MAAQ,EAAQ,EACtB,GAAS,EAAM,OACf,EAAQ,QACR,GAAG,EAAO,EACZ,IAAG,SAAU,GACX,GAAS,EACT,aAAa,GACT,EACF,GAAG,MAAM,GAAI,WAEX,IACA,cAAa,WACX,EAAE,KAAK,QACT,GACF,IAEA,GAEJ,IAIA,OAEA,SAAS,IACP,GAAI,EAAQ,OAEP,EAaH,IAZA,GAAG,KAAK,EAAM,KAAK,SAAU,EAAK,GAChC,GAAI,EACE,GAAK,GAAG,MAAM,OADpB,CAIA,GAAI,EAAK,OAAO,EAAE,KAAK,QAAS,GAEhC,EAAK,EACL,EAAE,KAAK,OAAQ,GACf,GALA,CAMF,IAKF,SAAS,IAEP,IAAI,EAAO,CAAC,MAAO,EAAQ,EAE3B,WAAiB,GACjB,EAAK,GAAK,EAEV,IAAI,EAAK,GAAG,iBAAiB,EAAM,GACnC,EAAG,KAAK,EAAG,CAAC,KAAK,IAEjB,IAAI,GAAI,SAAU,GAChB,GAAI,EAAK,OAAO,EAAE,KAAK,QAAS,GAChC,IAAI,EAAJ,CAEA,IAAI,EAAO,EAAQ,WACnB,EAAE,KAAK,UAAW,GAClB,EAAU,YAAW,WACnB,GACF,GAAG,EANS,CAOd,GACF,CACF,CA5CA,GAEO,CA2CT,CA5EA,OAAO,QAAU","file":"/npm/keep-reading@1.1.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/keep-reading@1.1.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var fs = require('fs')\nvar eos = require('end-of-stream')\nvar through2 = require('through2')\nvar Backo = require('backo')\n\n// dont stop reading this file and writing it's data to the output stream.\nmodule.exports = keepReading\n\nfunction keepReading (file, start) {\n  var backoff = new Backo({min: 100, max: 5000})\n  var ending = false\n  var fd\n  var timeout\n\n  start = +start || -1\n  // must be an object stream of buffers because we set offset property to identify where in the file this buffer starts.\n  var s = through2.obj(function (chunk, enc, cb) {\n    chunk.start = start + 1\n    start += chunk.length\n    backoff.reset()\n    cb(false, chunk)\n  }, function (cb) {\n    ending = true\n    clearTimeout(timeout)\n    if (fd) {\n      fs.close(fd, function () {\n        // handle close error... can this error in a way that results in an fd leak?\n        cb()\n        setImmediate(function () {\n          s.emit('close')\n        })\n      })\n    } else {\n      cb()\n    }\n  })\n\n  makeStream(start)\n\n  return s\n\n  function makeStream () {\n    if (ending) return\n\n    if (!fd) {\n      fs.open(file, 'r', function (err, _fd) {\n        if (ending) {\n          if (_fd) fs.close(_fd)\n          return\n        }\n        if (err) return s.emit('error', err)\n\n        fd = _fd\n        s.emit('open', fd)\n        stream()\n      })\n    } else {\n      stream()\n    }\n\n    function stream () {\n      // start is inclusive\n      var opts = {start: start + 1}\n      // reuse fd and do not close it when read stream is done.\n      opts.autoClose = false\n      opts.fd = fd\n\n      var rs = fs.createReadStream(file, opts)\n      rs.pipe(s, {end: false})\n\n      eos(rs, function (err) {\n        if (err) return s.emit('error', err)\n        if (ending) return\n\n        var wait = backoff.duration()\n        s.emit('waiting', wait)\n        timeout = setTimeout(function () {\n          makeStream()\n        }, wait)\n      })\n    }\n  }\n}\n"]}