{"version":3,"sources":["jsdelivr-header.js","/npm/random-access-latency@1.0.0/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,IAAM,QAAQ,yBAEpB,OAAO,QAAU,SAAU,EAAS,GAC7B,MAAM,QAAQ,KAAU,EAAU,CAAC,EAAS,IAEjD,MAAM,EAAQ,EAAQ,GAAK,EAAQ,GAEnC,OAAO,IAAI,CACT,KAAM,EAAI,GACV,MAAO,EAAI,GACX,IAAK,EAAI,GACT,KAAM,EAAI,KAGZ,SAAS,EAAK,GACZ,OAAO,SAAU,GACf,MAAM,EAAU,KAAK,MAAM,KAAK,SAAW,EAAQ,EAAQ,IAC3D,YAAW,IAIf,SAAc,EAAM,GAClB,MAAM,EAAK,EAAI,SAAS,KAAK,GAE7B,OAAQ,GACN,KAAK,EAAG,OAAO,EAAM,KAAK,EAAI,OAAQ,EAAI,KAAM,GAChD,KAAK,EAAG,OAAO,EAAM,MAAM,EAAI,OAAQ,EAAI,KAAM,GACjD,KAAK,EAAG,OAAO,EAAM,IAAI,EAAI,OAAQ,EAAI,KAAM,GAC/C,KAAK,EAAG,OAAO,EAAM,KAAK,GAE9B,CAbqB,CAAI,EAAM,IAAM,EACnC,CACF,CAYF","file":"/npm/random-access-latency@1.0.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/random-access-latency@1.0.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","const ras = require('random-access-storage')\n\nmodule.exports = function (latency, other) {\n  if (!Array.isArray(latency)) latency = [latency, latency]\n\n  const delta = latency[1] - latency[0]\n\n  return ras({\n    read: run(0),\n    write: run(1),\n    del: run(2),\n    stat: run(3)\n  })\n\n  function run (type) {\n    return function (req) {\n      const timeout = Math.round(Math.random() * delta + latency[0])\n      setTimeout(() => fwd(type, req), timeout)\n    }\n  }\n\n  function fwd (type, req) {\n    const cb = req.callback.bind(req)\n\n    switch (type) {\n      case 0: return other.read(req.offset, req.size, cb)\n      case 1: return other.write(req.offset, req.data, cb)\n      case 2: return other.del(req.offset, req.size, cb)\n      case 3: return other.stat(cb)\n    }\n  }\n}\n"]}