korext 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (517) hide show
  1. package/bin/korext.js +278 -0
  2. package/korext-cli-0.1.0.tgz +0 -0
  3. package/node_modules/ansi-regex/index.d.ts +37 -0
  4. package/node_modules/ansi-regex/index.js +10 -0
  5. package/node_modules/ansi-regex/license +9 -0
  6. package/node_modules/ansi-regex/package.json +55 -0
  7. package/node_modules/ansi-regex/readme.md +78 -0
  8. package/node_modules/ansi-styles/index.d.ts +345 -0
  9. package/node_modules/ansi-styles/index.js +163 -0
  10. package/node_modules/ansi-styles/license +9 -0
  11. package/node_modules/ansi-styles/package.json +56 -0
  12. package/node_modules/ansi-styles/readme.md +152 -0
  13. package/node_modules/balanced-match/LICENSE.md +23 -0
  14. package/node_modules/balanced-match/README.md +57 -0
  15. package/node_modules/balanced-match/dist/commonjs/index.d.ts +9 -0
  16. package/node_modules/balanced-match/dist/commonjs/index.d.ts.map +1 -0
  17. package/node_modules/balanced-match/dist/commonjs/index.js +59 -0
  18. package/node_modules/balanced-match/dist/commonjs/index.js.map +1 -0
  19. package/node_modules/balanced-match/dist/commonjs/package.json +3 -0
  20. package/node_modules/balanced-match/dist/esm/index.d.ts +9 -0
  21. package/node_modules/balanced-match/dist/esm/index.d.ts.map +1 -0
  22. package/node_modules/balanced-match/dist/esm/index.js +54 -0
  23. package/node_modules/balanced-match/dist/esm/index.js.map +1 -0
  24. package/node_modules/balanced-match/dist/esm/package.json +3 -0
  25. package/node_modules/balanced-match/package.json +68 -0
  26. package/node_modules/base64-js/LICENSE +21 -0
  27. package/node_modules/base64-js/README.md +34 -0
  28. package/node_modules/base64-js/base64js.min.js +1 -0
  29. package/node_modules/base64-js/index.d.ts +3 -0
  30. package/node_modules/base64-js/index.js +150 -0
  31. package/node_modules/base64-js/package.json +47 -0
  32. package/node_modules/bl/.travis.yml +17 -0
  33. package/node_modules/bl/BufferList.js +396 -0
  34. package/node_modules/bl/LICENSE.md +13 -0
  35. package/node_modules/bl/README.md +247 -0
  36. package/node_modules/bl/bl.js +84 -0
  37. package/node_modules/bl/package.json +37 -0
  38. package/node_modules/bl/test/convert.js +21 -0
  39. package/node_modules/bl/test/indexOf.js +492 -0
  40. package/node_modules/bl/test/isBufferList.js +32 -0
  41. package/node_modules/bl/test/test.js +869 -0
  42. package/node_modules/brace-expansion/LICENSE +23 -0
  43. package/node_modules/brace-expansion/README.md +94 -0
  44. package/node_modules/brace-expansion/dist/commonjs/index.d.ts +6 -0
  45. package/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +1 -0
  46. package/node_modules/brace-expansion/dist/commonjs/index.js +199 -0
  47. package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -0
  48. package/node_modules/brace-expansion/dist/commonjs/package.json +3 -0
  49. package/node_modules/brace-expansion/dist/esm/index.d.ts +6 -0
  50. package/node_modules/brace-expansion/dist/esm/index.d.ts.map +1 -0
  51. package/node_modules/brace-expansion/dist/esm/index.js +195 -0
  52. package/node_modules/brace-expansion/dist/esm/index.js.map +1 -0
  53. package/node_modules/brace-expansion/dist/esm/package.json +3 -0
  54. package/node_modules/brace-expansion/package.json +64 -0
  55. package/node_modules/buffer/AUTHORS.md +70 -0
  56. package/node_modules/buffer/LICENSE +21 -0
  57. package/node_modules/buffer/README.md +410 -0
  58. package/node_modules/buffer/index.d.ts +186 -0
  59. package/node_modules/buffer/index.js +1817 -0
  60. package/node_modules/buffer/package.json +96 -0
  61. package/node_modules/chalk/index.d.ts +415 -0
  62. package/node_modules/chalk/license +9 -0
  63. package/node_modules/chalk/package.json +68 -0
  64. package/node_modules/chalk/readme.md +341 -0
  65. package/node_modules/chalk/source/index.js +229 -0
  66. package/node_modules/chalk/source/templates.js +134 -0
  67. package/node_modules/chalk/source/util.js +39 -0
  68. package/node_modules/cli-cursor/index.d.ts +45 -0
  69. package/node_modules/cli-cursor/index.js +35 -0
  70. package/node_modules/cli-cursor/license +9 -0
  71. package/node_modules/cli-cursor/package.json +46 -0
  72. package/node_modules/cli-cursor/readme.md +55 -0
  73. package/node_modules/cli-spinners/index.d.ts +128 -0
  74. package/node_modules/cli-spinners/index.js +15 -0
  75. package/node_modules/cli-spinners/license +9 -0
  76. package/node_modules/cli-spinners/package.json +50 -0
  77. package/node_modules/cli-spinners/readme.md +54 -0
  78. package/node_modules/cli-spinners/spinners.json +1622 -0
  79. package/node_modules/clone/.npmignore +4 -0
  80. package/node_modules/clone/LICENSE +18 -0
  81. package/node_modules/clone/README.md +126 -0
  82. package/node_modules/clone/clone.iml +10 -0
  83. package/node_modules/clone/clone.js +166 -0
  84. package/node_modules/clone/package.json +51 -0
  85. package/node_modules/color-convert/CHANGELOG.md +54 -0
  86. package/node_modules/color-convert/LICENSE +21 -0
  87. package/node_modules/color-convert/README.md +68 -0
  88. package/node_modules/color-convert/conversions.js +839 -0
  89. package/node_modules/color-convert/index.js +81 -0
  90. package/node_modules/color-convert/package.json +48 -0
  91. package/node_modules/color-convert/route.js +97 -0
  92. package/node_modules/color-name/LICENSE +8 -0
  93. package/node_modules/color-name/README.md +11 -0
  94. package/node_modules/color-name/index.js +152 -0
  95. package/node_modules/color-name/package.json +28 -0
  96. package/node_modules/commander/LICENSE +22 -0
  97. package/node_modules/commander/Readme.md +1176 -0
  98. package/node_modules/commander/esm.mjs +16 -0
  99. package/node_modules/commander/index.js +24 -0
  100. package/node_modules/commander/lib/argument.js +150 -0
  101. package/node_modules/commander/lib/command.js +2777 -0
  102. package/node_modules/commander/lib/error.js +39 -0
  103. package/node_modules/commander/lib/help.js +747 -0
  104. package/node_modules/commander/lib/option.js +380 -0
  105. package/node_modules/commander/lib/suggestSimilar.js +101 -0
  106. package/node_modules/commander/package-support.json +19 -0
  107. package/node_modules/commander/package.json +82 -0
  108. package/node_modules/commander/typings/esm.d.mts +3 -0
  109. package/node_modules/commander/typings/index.d.ts +1113 -0
  110. package/node_modules/data-uri-to-buffer/README.md +88 -0
  111. package/node_modules/data-uri-to-buffer/dist/index.d.ts +15 -0
  112. package/node_modules/data-uri-to-buffer/dist/index.js +53 -0
  113. package/node_modules/data-uri-to-buffer/dist/index.js.map +1 -0
  114. package/node_modules/data-uri-to-buffer/package.json +62 -0
  115. package/node_modules/data-uri-to-buffer/src/index.ts +68 -0
  116. package/node_modules/defaults/LICENSE +22 -0
  117. package/node_modules/defaults/README.md +39 -0
  118. package/node_modules/defaults/index.js +13 -0
  119. package/node_modules/defaults/package.json +33 -0
  120. package/node_modules/defaults/test.js +34 -0
  121. package/node_modules/fetch-blob/LICENSE +21 -0
  122. package/node_modules/fetch-blob/README.md +106 -0
  123. package/node_modules/fetch-blob/file.d.ts +2 -0
  124. package/node_modules/fetch-blob/file.js +49 -0
  125. package/node_modules/fetch-blob/from.d.ts +26 -0
  126. package/node_modules/fetch-blob/from.js +100 -0
  127. package/node_modules/fetch-blob/index.d.ts +3 -0
  128. package/node_modules/fetch-blob/index.js +250 -0
  129. package/node_modules/fetch-blob/package.json +56 -0
  130. package/node_modules/fetch-blob/streams.cjs +51 -0
  131. package/node_modules/formdata-polyfill/FormData.js +441 -0
  132. package/node_modules/formdata-polyfill/LICENSE +21 -0
  133. package/node_modules/formdata-polyfill/README.md +145 -0
  134. package/node_modules/formdata-polyfill/esm.min.d.ts +5 -0
  135. package/node_modules/formdata-polyfill/esm.min.js +40 -0
  136. package/node_modules/formdata-polyfill/formdata-to-blob.js +39 -0
  137. package/node_modules/formdata-polyfill/formdata.min.js +21 -0
  138. package/node_modules/formdata-polyfill/package.json +50 -0
  139. package/node_modules/glob/LICENSE.md +63 -0
  140. package/node_modules/glob/README.md +1203 -0
  141. package/node_modules/glob/dist/commonjs/glob.d.ts +396 -0
  142. package/node_modules/glob/dist/commonjs/glob.d.ts.map +1 -0
  143. package/node_modules/glob/dist/commonjs/glob.js +248 -0
  144. package/node_modules/glob/dist/commonjs/glob.js.map +1 -0
  145. package/node_modules/glob/dist/commonjs/has-magic.d.ts +14 -0
  146. package/node_modules/glob/dist/commonjs/has-magic.d.ts.map +1 -0
  147. package/node_modules/glob/dist/commonjs/has-magic.js +27 -0
  148. package/node_modules/glob/dist/commonjs/has-magic.js.map +1 -0
  149. package/node_modules/glob/dist/commonjs/ignore.d.ts +24 -0
  150. package/node_modules/glob/dist/commonjs/ignore.d.ts.map +1 -0
  151. package/node_modules/glob/dist/commonjs/ignore.js +119 -0
  152. package/node_modules/glob/dist/commonjs/ignore.js.map +1 -0
  153. package/node_modules/glob/dist/commonjs/index.d.ts +97 -0
  154. package/node_modules/glob/dist/commonjs/index.d.ts.map +1 -0
  155. package/node_modules/glob/dist/commonjs/index.js +68 -0
  156. package/node_modules/glob/dist/commonjs/index.js.map +1 -0
  157. package/node_modules/glob/dist/commonjs/index.min.js +4 -0
  158. package/node_modules/glob/dist/commonjs/index.min.js.map +7 -0
  159. package/node_modules/glob/dist/commonjs/package.json +3 -0
  160. package/node_modules/glob/dist/commonjs/pattern.d.ts +79 -0
  161. package/node_modules/glob/dist/commonjs/pattern.d.ts.map +1 -0
  162. package/node_modules/glob/dist/commonjs/pattern.js +223 -0
  163. package/node_modules/glob/dist/commonjs/pattern.js.map +1 -0
  164. package/node_modules/glob/dist/commonjs/processor.d.ts +59 -0
  165. package/node_modules/glob/dist/commonjs/processor.d.ts.map +1 -0
  166. package/node_modules/glob/dist/commonjs/processor.js +301 -0
  167. package/node_modules/glob/dist/commonjs/processor.js.map +1 -0
  168. package/node_modules/glob/dist/commonjs/walker.d.ts +97 -0
  169. package/node_modules/glob/dist/commonjs/walker.d.ts.map +1 -0
  170. package/node_modules/glob/dist/commonjs/walker.js +387 -0
  171. package/node_modules/glob/dist/commonjs/walker.js.map +1 -0
  172. package/node_modules/glob/dist/esm/glob.d.ts +396 -0
  173. package/node_modules/glob/dist/esm/glob.d.ts.map +1 -0
  174. package/node_modules/glob/dist/esm/glob.js +244 -0
  175. package/node_modules/glob/dist/esm/glob.js.map +1 -0
  176. package/node_modules/glob/dist/esm/has-magic.d.ts +14 -0
  177. package/node_modules/glob/dist/esm/has-magic.d.ts.map +1 -0
  178. package/node_modules/glob/dist/esm/has-magic.js +23 -0
  179. package/node_modules/glob/dist/esm/has-magic.js.map +1 -0
  180. package/node_modules/glob/dist/esm/ignore.d.ts +24 -0
  181. package/node_modules/glob/dist/esm/ignore.d.ts.map +1 -0
  182. package/node_modules/glob/dist/esm/ignore.js +115 -0
  183. package/node_modules/glob/dist/esm/ignore.js.map +1 -0
  184. package/node_modules/glob/dist/esm/index.d.ts +97 -0
  185. package/node_modules/glob/dist/esm/index.d.ts.map +1 -0
  186. package/node_modules/glob/dist/esm/index.js +55 -0
  187. package/node_modules/glob/dist/esm/index.js.map +1 -0
  188. package/node_modules/glob/dist/esm/index.min.js +4 -0
  189. package/node_modules/glob/dist/esm/index.min.js.map +7 -0
  190. package/node_modules/glob/dist/esm/package.json +3 -0
  191. package/node_modules/glob/dist/esm/pattern.d.ts +79 -0
  192. package/node_modules/glob/dist/esm/pattern.d.ts.map +1 -0
  193. package/node_modules/glob/dist/esm/pattern.js +219 -0
  194. package/node_modules/glob/dist/esm/pattern.js.map +1 -0
  195. package/node_modules/glob/dist/esm/processor.d.ts +59 -0
  196. package/node_modules/glob/dist/esm/processor.d.ts.map +1 -0
  197. package/node_modules/glob/dist/esm/processor.js +294 -0
  198. package/node_modules/glob/dist/esm/processor.js.map +1 -0
  199. package/node_modules/glob/dist/esm/walker.d.ts +97 -0
  200. package/node_modules/glob/dist/esm/walker.d.ts.map +1 -0
  201. package/node_modules/glob/dist/esm/walker.js +381 -0
  202. package/node_modules/glob/dist/esm/walker.js.map +1 -0
  203. package/node_modules/glob/package.json +98 -0
  204. package/node_modules/has-flag/index.d.ts +39 -0
  205. package/node_modules/has-flag/index.js +8 -0
  206. package/node_modules/has-flag/license +9 -0
  207. package/node_modules/has-flag/package.json +46 -0
  208. package/node_modules/has-flag/readme.md +89 -0
  209. package/node_modules/ieee754/LICENSE +11 -0
  210. package/node_modules/ieee754/README.md +51 -0
  211. package/node_modules/ieee754/index.d.ts +10 -0
  212. package/node_modules/ieee754/index.js +85 -0
  213. package/node_modules/ieee754/package.json +52 -0
  214. package/node_modules/inherits/LICENSE +16 -0
  215. package/node_modules/inherits/README.md +42 -0
  216. package/node_modules/inherits/inherits.js +9 -0
  217. package/node_modules/inherits/inherits_browser.js +27 -0
  218. package/node_modules/inherits/package.json +29 -0
  219. package/node_modules/is-interactive/index.d.ts +31 -0
  220. package/node_modules/is-interactive/index.js +9 -0
  221. package/node_modules/is-interactive/license +9 -0
  222. package/node_modules/is-interactive/package.json +38 -0
  223. package/node_modules/is-interactive/readme.md +51 -0
  224. package/node_modules/is-unicode-supported/index.d.ts +14 -0
  225. package/node_modules/is-unicode-supported/index.js +13 -0
  226. package/node_modules/is-unicode-supported/license +9 -0
  227. package/node_modules/is-unicode-supported/package.json +41 -0
  228. package/node_modules/is-unicode-supported/readme.md +35 -0
  229. package/node_modules/log-symbols/browser.js +8 -0
  230. package/node_modules/log-symbols/index.d.ts +25 -0
  231. package/node_modules/log-symbols/index.js +19 -0
  232. package/node_modules/log-symbols/license +9 -0
  233. package/node_modules/log-symbols/package.json +52 -0
  234. package/node_modules/log-symbols/readme.md +51 -0
  235. package/node_modules/lru-cache/LICENSE.md +55 -0
  236. package/node_modules/lru-cache/README.md +383 -0
  237. package/node_modules/lru-cache/dist/commonjs/index.d.ts +1323 -0
  238. package/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -0
  239. package/node_modules/lru-cache/dist/commonjs/index.js +1595 -0
  240. package/node_modules/lru-cache/dist/commonjs/index.js.map +1 -0
  241. package/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
  242. package/node_modules/lru-cache/dist/commonjs/index.min.js.map +7 -0
  243. package/node_modules/lru-cache/dist/commonjs/package.json +3 -0
  244. package/node_modules/lru-cache/dist/esm/index.d.ts +1323 -0
  245. package/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -0
  246. package/node_modules/lru-cache/dist/esm/index.js +1591 -0
  247. package/node_modules/lru-cache/dist/esm/index.js.map +1 -0
  248. package/node_modules/lru-cache/dist/esm/index.min.js +2 -0
  249. package/node_modules/lru-cache/dist/esm/index.min.js.map +7 -0
  250. package/node_modules/lru-cache/dist/esm/package.json +3 -0
  251. package/node_modules/lru-cache/package.json +93 -0
  252. package/node_modules/mimic-fn/index.d.ts +54 -0
  253. package/node_modules/mimic-fn/index.js +13 -0
  254. package/node_modules/mimic-fn/license +9 -0
  255. package/node_modules/mimic-fn/package.json +42 -0
  256. package/node_modules/mimic-fn/readme.md +69 -0
  257. package/node_modules/minimatch/LICENSE.md +55 -0
  258. package/node_modules/minimatch/README.md +528 -0
  259. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +2 -0
  260. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts.map +1 -0
  261. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
  262. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js.map +1 -0
  263. package/node_modules/minimatch/dist/commonjs/ast.d.ts +22 -0
  264. package/node_modules/minimatch/dist/commonjs/ast.d.ts.map +1 -0
  265. package/node_modules/minimatch/dist/commonjs/ast.js +846 -0
  266. package/node_modules/minimatch/dist/commonjs/ast.js.map +1 -0
  267. package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +8 -0
  268. package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +1 -0
  269. package/node_modules/minimatch/dist/commonjs/brace-expressions.js +150 -0
  270. package/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +1 -0
  271. package/node_modules/minimatch/dist/commonjs/escape.d.ts +15 -0
  272. package/node_modules/minimatch/dist/commonjs/escape.d.ts.map +1 -0
  273. package/node_modules/minimatch/dist/commonjs/escape.js +30 -0
  274. package/node_modules/minimatch/dist/commonjs/escape.js.map +1 -0
  275. package/node_modules/minimatch/dist/commonjs/index.d.ts +174 -0
  276. package/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -0
  277. package/node_modules/minimatch/dist/commonjs/index.js +1121 -0
  278. package/node_modules/minimatch/dist/commonjs/index.js.map +1 -0
  279. package/node_modules/minimatch/dist/commonjs/package.json +3 -0
  280. package/node_modules/minimatch/dist/commonjs/unescape.d.ts +22 -0
  281. package/node_modules/minimatch/dist/commonjs/unescape.d.ts.map +1 -0
  282. package/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
  283. package/node_modules/minimatch/dist/commonjs/unescape.js.map +1 -0
  284. package/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +2 -0
  285. package/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts.map +1 -0
  286. package/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
  287. package/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -0
  288. package/node_modules/minimatch/dist/esm/ast.d.ts +22 -0
  289. package/node_modules/minimatch/dist/esm/ast.d.ts.map +1 -0
  290. package/node_modules/minimatch/dist/esm/ast.js +842 -0
  291. package/node_modules/minimatch/dist/esm/ast.js.map +1 -0
  292. package/node_modules/minimatch/dist/esm/brace-expressions.d.ts +8 -0
  293. package/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +1 -0
  294. package/node_modules/minimatch/dist/esm/brace-expressions.js +146 -0
  295. package/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -0
  296. package/node_modules/minimatch/dist/esm/escape.d.ts +15 -0
  297. package/node_modules/minimatch/dist/esm/escape.d.ts.map +1 -0
  298. package/node_modules/minimatch/dist/esm/escape.js +26 -0
  299. package/node_modules/minimatch/dist/esm/escape.js.map +1 -0
  300. package/node_modules/minimatch/dist/esm/index.d.ts +174 -0
  301. package/node_modules/minimatch/dist/esm/index.d.ts.map +1 -0
  302. package/node_modules/minimatch/dist/esm/index.js +1108 -0
  303. package/node_modules/minimatch/dist/esm/index.js.map +1 -0
  304. package/node_modules/minimatch/dist/esm/package.json +3 -0
  305. package/node_modules/minimatch/dist/esm/unescape.d.ts +22 -0
  306. package/node_modules/minimatch/dist/esm/unescape.d.ts.map +1 -0
  307. package/node_modules/minimatch/dist/esm/unescape.js +34 -0
  308. package/node_modules/minimatch/dist/esm/unescape.js.map +1 -0
  309. package/node_modules/minimatch/package.json +67 -0
  310. package/node_modules/minipass/LICENSE.md +55 -0
  311. package/node_modules/minipass/README.md +825 -0
  312. package/node_modules/minipass/dist/commonjs/index.d.ts +545 -0
  313. package/node_modules/minipass/dist/commonjs/index.d.ts.map +1 -0
  314. package/node_modules/minipass/dist/commonjs/index.js +1038 -0
  315. package/node_modules/minipass/dist/commonjs/index.js.map +1 -0
  316. package/node_modules/minipass/dist/commonjs/package.json +3 -0
  317. package/node_modules/minipass/dist/esm/index.d.ts +545 -0
  318. package/node_modules/minipass/dist/esm/index.d.ts.map +1 -0
  319. package/node_modules/minipass/dist/esm/index.js +1020 -0
  320. package/node_modules/minipass/dist/esm/index.js.map +1 -0
  321. package/node_modules/minipass/dist/esm/package.json +3 -0
  322. package/node_modules/minipass/package.json +77 -0
  323. package/node_modules/node-domexception/.history/README_20210527203617.md +2 -0
  324. package/node_modules/node-domexception/.history/README_20210527212714.md +41 -0
  325. package/node_modules/node-domexception/.history/README_20210527213345.md +36 -0
  326. package/node_modules/node-domexception/.history/README_20210527213411.md +36 -0
  327. package/node_modules/node-domexception/.history/README_20210527213803.md +36 -0
  328. package/node_modules/node-domexception/.history/README_20210527214323.md +38 -0
  329. package/node_modules/node-domexception/.history/README_20210527214408.md +38 -0
  330. package/node_modules/node-domexception/.history/index_20210527203842.js +0 -0
  331. package/node_modules/node-domexception/.history/index_20210527203947.js +8 -0
  332. package/node_modules/node-domexception/.history/index_20210527204259.js +9 -0
  333. package/node_modules/node-domexception/.history/index_20210527204418.js +9 -0
  334. package/node_modules/node-domexception/.history/index_20210527204756.js +11 -0
  335. package/node_modules/node-domexception/.history/index_20210527204833.js +11 -0
  336. package/node_modules/node-domexception/.history/index_20210527211208.js +15 -0
  337. package/node_modules/node-domexception/.history/index_20210527211248.js +15 -0
  338. package/node_modules/node-domexception/.history/index_20210527212722.js +23 -0
  339. package/node_modules/node-domexception/.history/index_20210527212731.js +23 -0
  340. package/node_modules/node-domexception/.history/index_20210527212746.js +15 -0
  341. package/node_modules/node-domexception/.history/index_20210527212900.js +16 -0
  342. package/node_modules/node-domexception/.history/index_20210527213022.js +16 -0
  343. package/node_modules/node-domexception/.history/index_20210527213822.js +16 -0
  344. package/node_modules/node-domexception/.history/index_20210527213843.js +17 -0
  345. package/node_modules/node-domexception/.history/index_20210527213852.js +17 -0
  346. package/node_modules/node-domexception/.history/index_20210527213910.js +16 -0
  347. package/node_modules/node-domexception/.history/index_20210527214034.js +16 -0
  348. package/node_modules/node-domexception/.history/index_20210527214643.js +41 -0
  349. package/node_modules/node-domexception/.history/index_20210527214654.js +41 -0
  350. package/node_modules/node-domexception/.history/index_20210527214700.js +16 -0
  351. package/node_modules/node-domexception/.history/package_20210527203733.json +19 -0
  352. package/node_modules/node-domexception/.history/package_20210527203825.json +16 -0
  353. package/node_modules/node-domexception/.history/package_20210527204621.json +19 -0
  354. package/node_modules/node-domexception/.history/package_20210527204913.json +25 -0
  355. package/node_modules/node-domexception/.history/package_20210527204925.json +25 -0
  356. package/node_modules/node-domexception/.history/package_20210527205145.json +29 -0
  357. package/node_modules/node-domexception/.history/package_20210527205156.json +29 -0
  358. package/node_modules/node-domexception/.history/test_20210527205603.js +0 -0
  359. package/node_modules/node-domexception/.history/test_20210527205957.js +3 -0
  360. package/node_modules/node-domexception/.history/test_20210527210021.js +3 -0
  361. package/node_modules/node-domexception/LICENSE +21 -0
  362. package/node_modules/node-domexception/README.md +46 -0
  363. package/node_modules/node-domexception/index.js +16 -0
  364. package/node_modules/node-domexception/package.json +29 -0
  365. package/node_modules/node-fetch/@types/index.d.ts +219 -0
  366. package/node_modules/node-fetch/LICENSE.md +22 -0
  367. package/node_modules/node-fetch/README.md +872 -0
  368. package/node_modules/node-fetch/package.json +131 -0
  369. package/node_modules/node-fetch/src/body.js +397 -0
  370. package/node_modules/node-fetch/src/errors/abort-error.js +10 -0
  371. package/node_modules/node-fetch/src/errors/base.js +17 -0
  372. package/node_modules/node-fetch/src/errors/fetch-error.js +26 -0
  373. package/node_modules/node-fetch/src/headers.js +267 -0
  374. package/node_modules/node-fetch/src/index.js +417 -0
  375. package/node_modules/node-fetch/src/request.js +313 -0
  376. package/node_modules/node-fetch/src/response.js +160 -0
  377. package/node_modules/node-fetch/src/utils/get-search.js +9 -0
  378. package/node_modules/node-fetch/src/utils/is-redirect.js +11 -0
  379. package/node_modules/node-fetch/src/utils/is.js +87 -0
  380. package/node_modules/node-fetch/src/utils/multipart-parser.js +432 -0
  381. package/node_modules/node-fetch/src/utils/referrer.js +340 -0
  382. package/node_modules/onetime/index.d.ts +64 -0
  383. package/node_modules/onetime/index.js +44 -0
  384. package/node_modules/onetime/license +9 -0
  385. package/node_modules/onetime/package.json +43 -0
  386. package/node_modules/onetime/readme.md +94 -0
  387. package/node_modules/ora/index.d.ts +277 -0
  388. package/node_modules/ora/index.js +407 -0
  389. package/node_modules/ora/license +9 -0
  390. package/node_modules/ora/package.json +57 -0
  391. package/node_modules/ora/readme.md +264 -0
  392. package/node_modules/path-scurry/LICENSE.md +55 -0
  393. package/node_modules/path-scurry/README.md +636 -0
  394. package/node_modules/path-scurry/dist/commonjs/index.d.ts +1115 -0
  395. package/node_modules/path-scurry/dist/commonjs/index.d.ts.map +1 -0
  396. package/node_modules/path-scurry/dist/commonjs/index.js +2018 -0
  397. package/node_modules/path-scurry/dist/commonjs/index.js.map +1 -0
  398. package/node_modules/path-scurry/dist/commonjs/package.json +3 -0
  399. package/node_modules/path-scurry/dist/esm/index.d.ts +1115 -0
  400. package/node_modules/path-scurry/dist/esm/index.d.ts.map +1 -0
  401. package/node_modules/path-scurry/dist/esm/index.js +1983 -0
  402. package/node_modules/path-scurry/dist/esm/index.js.map +1 -0
  403. package/node_modules/path-scurry/dist/esm/package.json +3 -0
  404. package/node_modules/path-scurry/package.json +72 -0
  405. package/node_modules/readable-stream/CONTRIBUTING.md +38 -0
  406. package/node_modules/readable-stream/GOVERNANCE.md +136 -0
  407. package/node_modules/readable-stream/LICENSE +47 -0
  408. package/node_modules/readable-stream/README.md +106 -0
  409. package/node_modules/readable-stream/errors-browser.js +127 -0
  410. package/node_modules/readable-stream/errors.js +116 -0
  411. package/node_modules/readable-stream/experimentalWarning.js +17 -0
  412. package/node_modules/readable-stream/lib/_stream_duplex.js +126 -0
  413. package/node_modules/readable-stream/lib/_stream_passthrough.js +37 -0
  414. package/node_modules/readable-stream/lib/_stream_readable.js +1027 -0
  415. package/node_modules/readable-stream/lib/_stream_transform.js +190 -0
  416. package/node_modules/readable-stream/lib/_stream_writable.js +641 -0
  417. package/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
  418. package/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
  419. package/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
  420. package/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
  421. package/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
  422. package/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
  423. package/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
  424. package/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
  425. package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  426. package/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  427. package/node_modules/readable-stream/package.json +68 -0
  428. package/node_modules/readable-stream/readable-browser.js +9 -0
  429. package/node_modules/readable-stream/readable.js +16 -0
  430. package/node_modules/restore-cursor/index.d.ts +13 -0
  431. package/node_modules/restore-cursor/index.js +9 -0
  432. package/node_modules/restore-cursor/license +9 -0
  433. package/node_modules/restore-cursor/package.json +52 -0
  434. package/node_modules/restore-cursor/readme.md +26 -0
  435. package/node_modules/safe-buffer/LICENSE +21 -0
  436. package/node_modules/safe-buffer/README.md +584 -0
  437. package/node_modules/safe-buffer/index.d.ts +187 -0
  438. package/node_modules/safe-buffer/index.js +65 -0
  439. package/node_modules/safe-buffer/package.json +51 -0
  440. package/node_modules/signal-exit/LICENSE.txt +16 -0
  441. package/node_modules/signal-exit/README.md +39 -0
  442. package/node_modules/signal-exit/index.js +202 -0
  443. package/node_modules/signal-exit/package.json +38 -0
  444. package/node_modules/signal-exit/signals.js +53 -0
  445. package/node_modules/string_decoder/LICENSE +48 -0
  446. package/node_modules/string_decoder/README.md +47 -0
  447. package/node_modules/string_decoder/lib/string_decoder.js +296 -0
  448. package/node_modules/string_decoder/package.json +34 -0
  449. package/node_modules/strip-ansi/index.d.ts +17 -0
  450. package/node_modules/strip-ansi/index.js +4 -0
  451. package/node_modules/strip-ansi/license +9 -0
  452. package/node_modules/strip-ansi/package.json +54 -0
  453. package/node_modules/strip-ansi/readme.md +46 -0
  454. package/node_modules/supports-color/browser.js +5 -0
  455. package/node_modules/supports-color/index.js +135 -0
  456. package/node_modules/supports-color/license +9 -0
  457. package/node_modules/supports-color/package.json +53 -0
  458. package/node_modules/supports-color/readme.md +76 -0
  459. package/node_modules/util-deprecate/History.md +16 -0
  460. package/node_modules/util-deprecate/LICENSE +24 -0
  461. package/node_modules/util-deprecate/README.md +53 -0
  462. package/node_modules/util-deprecate/browser.js +67 -0
  463. package/node_modules/util-deprecate/node.js +6 -0
  464. package/node_modules/util-deprecate/package.json +27 -0
  465. package/node_modules/wcwidth/.npmignore +1 -0
  466. package/node_modules/wcwidth/LICENSE +30 -0
  467. package/node_modules/wcwidth/Readme.md +33 -0
  468. package/node_modules/wcwidth/combining.js +50 -0
  469. package/node_modules/wcwidth/docs/index.md +65 -0
  470. package/node_modules/wcwidth/index.js +99 -0
  471. package/node_modules/wcwidth/package.json +42 -0
  472. package/node_modules/wcwidth/test/index.js +64 -0
  473. package/node_modules/web-streams-polyfill/LICENSE +22 -0
  474. package/node_modules/web-streams-polyfill/README.md +110 -0
  475. package/node_modules/web-streams-polyfill/dist/polyfill.es2018.js +4765 -0
  476. package/node_modules/web-streams-polyfill/dist/polyfill.es2018.js.map +1 -0
  477. package/node_modules/web-streams-polyfill/dist/polyfill.es2018.min.js +9 -0
  478. package/node_modules/web-streams-polyfill/dist/polyfill.es2018.min.js.map +1 -0
  479. package/node_modules/web-streams-polyfill/dist/polyfill.es2018.mjs +4745 -0
  480. package/node_modules/web-streams-polyfill/dist/polyfill.es2018.mjs.map +1 -0
  481. package/node_modules/web-streams-polyfill/dist/polyfill.es6.js +4838 -0
  482. package/node_modules/web-streams-polyfill/dist/polyfill.es6.js.map +1 -0
  483. package/node_modules/web-streams-polyfill/dist/polyfill.es6.min.js +9 -0
  484. package/node_modules/web-streams-polyfill/dist/polyfill.es6.min.js.map +1 -0
  485. package/node_modules/web-streams-polyfill/dist/polyfill.es6.mjs +4818 -0
  486. package/node_modules/web-streams-polyfill/dist/polyfill.es6.mjs.map +1 -0
  487. package/node_modules/web-streams-polyfill/dist/polyfill.js +5011 -0
  488. package/node_modules/web-streams-polyfill/dist/polyfill.js.map +1 -0
  489. package/node_modules/web-streams-polyfill/dist/polyfill.min.js +9 -0
  490. package/node_modules/web-streams-polyfill/dist/polyfill.min.js.map +1 -0
  491. package/node_modules/web-streams-polyfill/dist/polyfill.mjs +4991 -0
  492. package/node_modules/web-streams-polyfill/dist/polyfill.mjs.map +1 -0
  493. package/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js +4737 -0
  494. package/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js.map +1 -0
  495. package/node_modules/web-streams-polyfill/dist/ponyfill.es2018.mjs +4717 -0
  496. package/node_modules/web-streams-polyfill/dist/ponyfill.es2018.mjs.map +1 -0
  497. package/node_modules/web-streams-polyfill/dist/ponyfill.es6.js +4810 -0
  498. package/node_modules/web-streams-polyfill/dist/ponyfill.es6.js.map +1 -0
  499. package/node_modules/web-streams-polyfill/dist/ponyfill.es6.mjs +4790 -0
  500. package/node_modules/web-streams-polyfill/dist/ponyfill.es6.mjs.map +1 -0
  501. package/node_modules/web-streams-polyfill/dist/ponyfill.js +4983 -0
  502. package/node_modules/web-streams-polyfill/dist/ponyfill.js.map +1 -0
  503. package/node_modules/web-streams-polyfill/dist/ponyfill.mjs +4963 -0
  504. package/node_modules/web-streams-polyfill/dist/ponyfill.mjs.map +1 -0
  505. package/node_modules/web-streams-polyfill/dist/types/polyfill.d.ts +24 -0
  506. package/node_modules/web-streams-polyfill/dist/types/ponyfill.d.ts +780 -0
  507. package/node_modules/web-streams-polyfill/dist/types/ts3.6/polyfill.d.ts +28 -0
  508. package/node_modules/web-streams-polyfill/dist/types/ts3.6/ponyfill.d.ts +821 -0
  509. package/node_modules/web-streams-polyfill/dist/types/tsdoc-metadata.json +11 -0
  510. package/node_modules/web-streams-polyfill/es2018/package.json +14 -0
  511. package/node_modules/web-streams-polyfill/es6/package.json +14 -0
  512. package/node_modules/web-streams-polyfill/package.json +83 -0
  513. package/node_modules/web-streams-polyfill/ponyfill/es2018/package.json +13 -0
  514. package/node_modules/web-streams-polyfill/ponyfill/es6/package.json +13 -0
  515. package/node_modules/web-streams-polyfill/ponyfill/package.json +13 -0
  516. package/package.json +26 -0
  517. package/version.json +18 -0
@@ -0,0 +1,1595 @@
1
+ "use strict";
2
+ /**
3
+ * @module LRUCache
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LRUCache = void 0;
7
+ const defaultPerf = (typeof performance === 'object' &&
8
+ performance &&
9
+ typeof performance.now === 'function') ?
10
+ performance
11
+ : Date;
12
+ const warned = new Set();
13
+ /* c8 ignore start */
14
+ const PROCESS = (typeof process === 'object' && !!process ?
15
+ process
16
+ : {});
17
+ /* c8 ignore start */
18
+ const emitWarning = (msg, type, code, fn) => {
19
+ typeof PROCESS.emitWarning === 'function' ?
20
+ PROCESS.emitWarning(msg, type, code, fn)
21
+ : console.error(`[${code}] ${type}: ${msg}`);
22
+ };
23
+ let AC = globalThis.AbortController;
24
+ let AS = globalThis.AbortSignal;
25
+ /* c8 ignore start */
26
+ if (typeof AC === 'undefined') {
27
+ //@ts-ignore
28
+ AS = class AbortSignal {
29
+ onabort;
30
+ _onabort = [];
31
+ reason;
32
+ aborted = false;
33
+ addEventListener(_, fn) {
34
+ this._onabort.push(fn);
35
+ }
36
+ };
37
+ //@ts-ignore
38
+ AC = class AbortController {
39
+ constructor() {
40
+ warnACPolyfill();
41
+ }
42
+ signal = new AS();
43
+ abort(reason) {
44
+ if (this.signal.aborted)
45
+ return;
46
+ //@ts-ignore
47
+ this.signal.reason = reason;
48
+ //@ts-ignore
49
+ this.signal.aborted = true;
50
+ //@ts-ignore
51
+ for (const fn of this.signal._onabort) {
52
+ fn(reason);
53
+ }
54
+ this.signal.onabort?.(reason);
55
+ }
56
+ };
57
+ let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
58
+ const warnACPolyfill = () => {
59
+ if (!printACPolyfillWarning)
60
+ return;
61
+ printACPolyfillWarning = false;
62
+ emitWarning('AbortController is not defined. If using lru-cache in ' +
63
+ 'node 14, load an AbortController polyfill from the ' +
64
+ '`node-abort-controller` package. A minimal polyfill is ' +
65
+ 'provided for use by LRUCache.fetch(), but it should not be ' +
66
+ 'relied upon in other contexts (eg, passing it to other APIs that ' +
67
+ 'use AbortController/AbortSignal might have undesirable effects). ' +
68
+ 'You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.', 'NO_ABORT_CONTROLLER', 'ENOTSUP', warnACPolyfill);
69
+ };
70
+ }
71
+ /* c8 ignore stop */
72
+ const shouldWarn = (code) => !warned.has(code);
73
+ const TYPE = Symbol('type');
74
+ const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
75
+ /* c8 ignore start */
76
+ // This is a little bit ridiculous, tbh.
77
+ // The maximum array length is 2^32-1 or thereabouts on most JS impls.
78
+ // And well before that point, you're caching the entire world, I mean,
79
+ // that's ~32GB of just integers for the next/prev links, plus whatever
80
+ // else to hold that many keys and values. Just filling the memory with
81
+ // zeroes at init time is brutal when you get that big.
82
+ // But why not be complete?
83
+ // Maybe in the future, these limits will have expanded.
84
+ const getUintArray = (max) => !isPosInt(max) ? null
85
+ : max <= Math.pow(2, 8) ? Uint8Array
86
+ : max <= Math.pow(2, 16) ? Uint16Array
87
+ : max <= Math.pow(2, 32) ? Uint32Array
88
+ : max <= Number.MAX_SAFE_INTEGER ? ZeroArray
89
+ : null;
90
+ /* c8 ignore stop */
91
+ class ZeroArray extends Array {
92
+ constructor(size) {
93
+ super(size);
94
+ this.fill(0);
95
+ }
96
+ }
97
+ class Stack {
98
+ heap;
99
+ length;
100
+ // private constructor
101
+ static #constructing = false;
102
+ static create(max) {
103
+ const HeapCls = getUintArray(max);
104
+ if (!HeapCls)
105
+ return [];
106
+ Stack.#constructing = true;
107
+ const s = new Stack(max, HeapCls);
108
+ Stack.#constructing = false;
109
+ return s;
110
+ }
111
+ constructor(max, HeapCls) {
112
+ /* c8 ignore start */
113
+ if (!Stack.#constructing) {
114
+ throw new TypeError('instantiate Stack using Stack.create(n)');
115
+ }
116
+ /* c8 ignore stop */
117
+ this.heap = new HeapCls(max);
118
+ this.length = 0;
119
+ }
120
+ push(n) {
121
+ this.heap[this.length++] = n;
122
+ }
123
+ pop() {
124
+ return this.heap[--this.length];
125
+ }
126
+ }
127
+ /**
128
+ * Default export, the thing you're using this module to get.
129
+ *
130
+ * The `K` and `V` types define the key and value types, respectively. The
131
+ * optional `FC` type defines the type of the `context` object passed to
132
+ * `cache.fetch()` and `cache.memo()`.
133
+ *
134
+ * Keys and values **must not** be `null` or `undefined`.
135
+ *
136
+ * All properties from the options object (with the exception of `max`,
137
+ * `maxSize`, `fetchMethod`, `memoMethod`, `dispose` and `disposeAfter`) are
138
+ * added as normal public members. (The listed options are read-only getters.)
139
+ *
140
+ * Changing any of these will alter the defaults for subsequent method calls.
141
+ */
142
+ class LRUCache {
143
+ // options that cannot be changed without disaster
144
+ #max;
145
+ #maxSize;
146
+ #dispose;
147
+ #onInsert;
148
+ #disposeAfter;
149
+ #fetchMethod;
150
+ #memoMethod;
151
+ #perf;
152
+ /**
153
+ * {@link LRUCache.OptionsBase.perf}
154
+ */
155
+ get perf() {
156
+ return this.#perf;
157
+ }
158
+ /**
159
+ * {@link LRUCache.OptionsBase.ttl}
160
+ */
161
+ ttl;
162
+ /**
163
+ * {@link LRUCache.OptionsBase.ttlResolution}
164
+ */
165
+ ttlResolution;
166
+ /**
167
+ * {@link LRUCache.OptionsBase.ttlAutopurge}
168
+ */
169
+ ttlAutopurge;
170
+ /**
171
+ * {@link LRUCache.OptionsBase.updateAgeOnGet}
172
+ */
173
+ updateAgeOnGet;
174
+ /**
175
+ * {@link LRUCache.OptionsBase.updateAgeOnHas}
176
+ */
177
+ updateAgeOnHas;
178
+ /**
179
+ * {@link LRUCache.OptionsBase.allowStale}
180
+ */
181
+ allowStale;
182
+ /**
183
+ * {@link LRUCache.OptionsBase.noDisposeOnSet}
184
+ */
185
+ noDisposeOnSet;
186
+ /**
187
+ * {@link LRUCache.OptionsBase.noUpdateTTL}
188
+ */
189
+ noUpdateTTL;
190
+ /**
191
+ * {@link LRUCache.OptionsBase.maxEntrySize}
192
+ */
193
+ maxEntrySize;
194
+ /**
195
+ * {@link LRUCache.OptionsBase.sizeCalculation}
196
+ */
197
+ sizeCalculation;
198
+ /**
199
+ * {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
200
+ */
201
+ noDeleteOnFetchRejection;
202
+ /**
203
+ * {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
204
+ */
205
+ noDeleteOnStaleGet;
206
+ /**
207
+ * {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
208
+ */
209
+ allowStaleOnFetchAbort;
210
+ /**
211
+ * {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
212
+ */
213
+ allowStaleOnFetchRejection;
214
+ /**
215
+ * {@link LRUCache.OptionsBase.ignoreFetchAbort}
216
+ */
217
+ ignoreFetchAbort;
218
+ // computed properties
219
+ #size;
220
+ #calculatedSize;
221
+ #keyMap;
222
+ #keyList;
223
+ #valList;
224
+ #next;
225
+ #prev;
226
+ #head;
227
+ #tail;
228
+ #free;
229
+ #disposed;
230
+ #sizes;
231
+ #starts;
232
+ #ttls;
233
+ #autopurgeTimers;
234
+ #hasDispose;
235
+ #hasFetchMethod;
236
+ #hasDisposeAfter;
237
+ #hasOnInsert;
238
+ /**
239
+ * Do not call this method unless you need to inspect the
240
+ * inner workings of the cache. If anything returned by this
241
+ * object is modified in any way, strange breakage may occur.
242
+ *
243
+ * These fields are private for a reason!
244
+ *
245
+ * @internal
246
+ */
247
+ static unsafeExposeInternals(c) {
248
+ return {
249
+ // properties
250
+ starts: c.#starts,
251
+ ttls: c.#ttls,
252
+ autopurgeTimers: c.#autopurgeTimers,
253
+ sizes: c.#sizes,
254
+ keyMap: c.#keyMap,
255
+ keyList: c.#keyList,
256
+ valList: c.#valList,
257
+ next: c.#next,
258
+ prev: c.#prev,
259
+ get head() {
260
+ return c.#head;
261
+ },
262
+ get tail() {
263
+ return c.#tail;
264
+ },
265
+ free: c.#free,
266
+ // methods
267
+ isBackgroundFetch: (p) => c.#isBackgroundFetch(p),
268
+ backgroundFetch: (k, index, options, context) => c.#backgroundFetch(k, index, options, context),
269
+ moveToTail: (index) => c.#moveToTail(index),
270
+ indexes: (options) => c.#indexes(options),
271
+ rindexes: (options) => c.#rindexes(options),
272
+ isStale: (index) => c.#isStale(index),
273
+ };
274
+ }
275
+ // Protected read-only members
276
+ /**
277
+ * {@link LRUCache.OptionsBase.max} (read-only)
278
+ */
279
+ get max() {
280
+ return this.#max;
281
+ }
282
+ /**
283
+ * {@link LRUCache.OptionsBase.maxSize} (read-only)
284
+ */
285
+ get maxSize() {
286
+ return this.#maxSize;
287
+ }
288
+ /**
289
+ * The total computed size of items in the cache (read-only)
290
+ */
291
+ get calculatedSize() {
292
+ return this.#calculatedSize;
293
+ }
294
+ /**
295
+ * The number of items stored in the cache (read-only)
296
+ */
297
+ get size() {
298
+ return this.#size;
299
+ }
300
+ /**
301
+ * {@link LRUCache.OptionsBase.fetchMethod} (read-only)
302
+ */
303
+ get fetchMethod() {
304
+ return this.#fetchMethod;
305
+ }
306
+ get memoMethod() {
307
+ return this.#memoMethod;
308
+ }
309
+ /**
310
+ * {@link LRUCache.OptionsBase.dispose} (read-only)
311
+ */
312
+ get dispose() {
313
+ return this.#dispose;
314
+ }
315
+ /**
316
+ * {@link LRUCache.OptionsBase.onInsert} (read-only)
317
+ */
318
+ get onInsert() {
319
+ return this.#onInsert;
320
+ }
321
+ /**
322
+ * {@link LRUCache.OptionsBase.disposeAfter} (read-only)
323
+ */
324
+ get disposeAfter() {
325
+ return this.#disposeAfter;
326
+ }
327
+ constructor(options) {
328
+ const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf, } = options;
329
+ if (perf !== undefined) {
330
+ if (typeof perf?.now !== 'function') {
331
+ throw new TypeError('perf option must have a now() method if specified');
332
+ }
333
+ }
334
+ this.#perf = perf ?? defaultPerf;
335
+ if (max !== 0 && !isPosInt(max)) {
336
+ throw new TypeError('max option must be a nonnegative integer');
337
+ }
338
+ const UintArray = max ? getUintArray(max) : Array;
339
+ if (!UintArray) {
340
+ throw new Error('invalid max value: ' + max);
341
+ }
342
+ this.#max = max;
343
+ this.#maxSize = maxSize;
344
+ this.maxEntrySize = maxEntrySize || this.#maxSize;
345
+ this.sizeCalculation = sizeCalculation;
346
+ if (this.sizeCalculation) {
347
+ if (!this.#maxSize && !this.maxEntrySize) {
348
+ throw new TypeError('cannot set sizeCalculation without setting maxSize or maxEntrySize');
349
+ }
350
+ if (typeof this.sizeCalculation !== 'function') {
351
+ throw new TypeError('sizeCalculation set to non-function');
352
+ }
353
+ }
354
+ if (memoMethod !== undefined && typeof memoMethod !== 'function') {
355
+ throw new TypeError('memoMethod must be a function if defined');
356
+ }
357
+ this.#memoMethod = memoMethod;
358
+ if (fetchMethod !== undefined && typeof fetchMethod !== 'function') {
359
+ throw new TypeError('fetchMethod must be a function if specified');
360
+ }
361
+ this.#fetchMethod = fetchMethod;
362
+ this.#hasFetchMethod = !!fetchMethod;
363
+ this.#keyMap = new Map();
364
+ this.#keyList = new Array(max).fill(undefined);
365
+ this.#valList = new Array(max).fill(undefined);
366
+ this.#next = new UintArray(max);
367
+ this.#prev = new UintArray(max);
368
+ this.#head = 0;
369
+ this.#tail = 0;
370
+ this.#free = Stack.create(max);
371
+ this.#size = 0;
372
+ this.#calculatedSize = 0;
373
+ if (typeof dispose === 'function') {
374
+ this.#dispose = dispose;
375
+ }
376
+ if (typeof onInsert === 'function') {
377
+ this.#onInsert = onInsert;
378
+ }
379
+ if (typeof disposeAfter === 'function') {
380
+ this.#disposeAfter = disposeAfter;
381
+ this.#disposed = [];
382
+ }
383
+ else {
384
+ this.#disposeAfter = undefined;
385
+ this.#disposed = undefined;
386
+ }
387
+ this.#hasDispose = !!this.#dispose;
388
+ this.#hasOnInsert = !!this.#onInsert;
389
+ this.#hasDisposeAfter = !!this.#disposeAfter;
390
+ this.noDisposeOnSet = !!noDisposeOnSet;
391
+ this.noUpdateTTL = !!noUpdateTTL;
392
+ this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection;
393
+ this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection;
394
+ this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort;
395
+ this.ignoreFetchAbort = !!ignoreFetchAbort;
396
+ // NB: maxEntrySize is set to maxSize if it's set
397
+ if (this.maxEntrySize !== 0) {
398
+ if (this.#maxSize !== 0) {
399
+ if (!isPosInt(this.#maxSize)) {
400
+ throw new TypeError('maxSize must be a positive integer if specified');
401
+ }
402
+ }
403
+ if (!isPosInt(this.maxEntrySize)) {
404
+ throw new TypeError('maxEntrySize must be a positive integer if specified');
405
+ }
406
+ this.#initializeSizeTracking();
407
+ }
408
+ this.allowStale = !!allowStale;
409
+ this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
410
+ this.updateAgeOnGet = !!updateAgeOnGet;
411
+ this.updateAgeOnHas = !!updateAgeOnHas;
412
+ this.ttlResolution =
413
+ isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1;
414
+ this.ttlAutopurge = !!ttlAutopurge;
415
+ this.ttl = ttl || 0;
416
+ if (this.ttl) {
417
+ if (!isPosInt(this.ttl)) {
418
+ throw new TypeError('ttl must be a positive integer if specified');
419
+ }
420
+ this.#initializeTTLTracking();
421
+ }
422
+ // do not allow completely unbounded caches
423
+ if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) {
424
+ throw new TypeError('At least one of max, maxSize, or ttl is required');
425
+ }
426
+ if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
427
+ const code = 'LRU_CACHE_UNBOUNDED';
428
+ if (shouldWarn(code)) {
429
+ warned.add(code);
430
+ const msg = 'TTL caching without ttlAutopurge, max, or maxSize can ' +
431
+ 'result in unbounded memory consumption.';
432
+ emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache);
433
+ }
434
+ }
435
+ }
436
+ /**
437
+ * Return the number of ms left in the item's TTL. If item is not in cache,
438
+ * returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
439
+ */
440
+ getRemainingTTL(key) {
441
+ return this.#keyMap.has(key) ? Infinity : 0;
442
+ }
443
+ #initializeTTLTracking() {
444
+ const ttls = new ZeroArray(this.#max);
445
+ const starts = new ZeroArray(this.#max);
446
+ this.#ttls = ttls;
447
+ this.#starts = starts;
448
+ const purgeTimers = this.ttlAutopurge ?
449
+ new Array(this.#max)
450
+ : undefined;
451
+ this.#autopurgeTimers = purgeTimers;
452
+ this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
453
+ starts[index] = ttl !== 0 ? start : 0;
454
+ ttls[index] = ttl;
455
+ setPurgetTimer(index, ttl);
456
+ };
457
+ this.#updateItemAge = index => {
458
+ starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
459
+ setPurgetTimer(index, ttls[index]);
460
+ };
461
+ // clear out the purge timer if we're setting TTL to 0, and
462
+ // previously had a ttl purge timer running, so it doesn't
463
+ // fire unnecessarily. Don't need to do this if we're not doing
464
+ // autopurge.
465
+ const setPurgetTimer = !this.ttlAutopurge ?
466
+ () => { }
467
+ : (index, ttl) => {
468
+ if (purgeTimers?.[index]) {
469
+ clearTimeout(purgeTimers[index]);
470
+ purgeTimers[index] = undefined;
471
+ }
472
+ if (ttl && ttl !== 0 && purgeTimers) {
473
+ const t = setTimeout(() => {
474
+ if (this.#isStale(index)) {
475
+ this.#delete(this.#keyList[index], 'expire');
476
+ }
477
+ }, ttl + 1);
478
+ // unref() not supported on all platforms
479
+ /* c8 ignore start */
480
+ if (t.unref) {
481
+ t.unref();
482
+ }
483
+ /* c8 ignore stop */
484
+ purgeTimers[index] = t;
485
+ }
486
+ };
487
+ this.#statusTTL = (status, index) => {
488
+ if (ttls[index]) {
489
+ const ttl = ttls[index];
490
+ const start = starts[index];
491
+ /* c8 ignore next */
492
+ if (!ttl || !start)
493
+ return;
494
+ status.ttl = ttl;
495
+ status.start = start;
496
+ status.now = cachedNow || getNow();
497
+ const age = status.now - start;
498
+ status.remainingTTL = ttl - age;
499
+ }
500
+ };
501
+ // debounce calls to perf.now() to 1s so we're not hitting
502
+ // that costly call repeatedly.
503
+ let cachedNow = 0;
504
+ const getNow = () => {
505
+ const n = this.#perf.now();
506
+ if (this.ttlResolution > 0) {
507
+ cachedNow = n;
508
+ const t = setTimeout(() => (cachedNow = 0), this.ttlResolution);
509
+ // not available on all platforms
510
+ /* c8 ignore start */
511
+ if (t.unref) {
512
+ t.unref();
513
+ }
514
+ /* c8 ignore stop */
515
+ }
516
+ return n;
517
+ };
518
+ this.getRemainingTTL = key => {
519
+ const index = this.#keyMap.get(key);
520
+ if (index === undefined) {
521
+ return 0;
522
+ }
523
+ const ttl = ttls[index];
524
+ const start = starts[index];
525
+ if (!ttl || !start) {
526
+ return Infinity;
527
+ }
528
+ const age = (cachedNow || getNow()) - start;
529
+ return ttl - age;
530
+ };
531
+ this.#isStale = index => {
532
+ const s = starts[index];
533
+ const t = ttls[index];
534
+ return !!t && !!s && (cachedNow || getNow()) - s > t;
535
+ };
536
+ }
537
+ // conditionally set private methods related to TTL
538
+ #updateItemAge = () => { };
539
+ #statusTTL = () => { };
540
+ #setItemTTL = () => { };
541
+ /* c8 ignore stop */
542
+ #isStale = () => false;
543
+ #initializeSizeTracking() {
544
+ const sizes = new ZeroArray(this.#max);
545
+ this.#calculatedSize = 0;
546
+ this.#sizes = sizes;
547
+ this.#removeItemSize = index => {
548
+ this.#calculatedSize -= sizes[index];
549
+ sizes[index] = 0;
550
+ };
551
+ this.#requireSize = (k, v, size, sizeCalculation) => {
552
+ // provisionally accept background fetches.
553
+ // actual value size will be checked when they return.
554
+ if (this.#isBackgroundFetch(v)) {
555
+ return 0;
556
+ }
557
+ if (!isPosInt(size)) {
558
+ if (sizeCalculation) {
559
+ if (typeof sizeCalculation !== 'function') {
560
+ throw new TypeError('sizeCalculation must be a function');
561
+ }
562
+ size = sizeCalculation(v, k);
563
+ if (!isPosInt(size)) {
564
+ throw new TypeError('sizeCalculation return invalid (expect positive integer)');
565
+ }
566
+ }
567
+ else {
568
+ throw new TypeError('invalid size value (must be positive integer). ' +
569
+ 'When maxSize or maxEntrySize is used, sizeCalculation ' +
570
+ 'or size must be set.');
571
+ }
572
+ }
573
+ return size;
574
+ };
575
+ this.#addItemSize = (index, size, status) => {
576
+ sizes[index] = size;
577
+ if (this.#maxSize) {
578
+ const maxSize = this.#maxSize - sizes[index];
579
+ while (this.#calculatedSize > maxSize) {
580
+ this.#evict(true);
581
+ }
582
+ }
583
+ this.#calculatedSize += sizes[index];
584
+ if (status) {
585
+ status.entrySize = size;
586
+ status.totalCalculatedSize = this.#calculatedSize;
587
+ }
588
+ };
589
+ }
590
+ #removeItemSize = _i => { };
591
+ #addItemSize = (_i, _s, _st) => { };
592
+ #requireSize = (_k, _v, size, sizeCalculation) => {
593
+ if (size || sizeCalculation) {
594
+ throw new TypeError('cannot set size without setting maxSize or maxEntrySize on cache');
595
+ }
596
+ return 0;
597
+ };
598
+ *#indexes({ allowStale = this.allowStale } = {}) {
599
+ if (this.#size) {
600
+ for (let i = this.#tail; true;) {
601
+ if (!this.#isValidIndex(i)) {
602
+ break;
603
+ }
604
+ if (allowStale || !this.#isStale(i)) {
605
+ yield i;
606
+ }
607
+ if (i === this.#head) {
608
+ break;
609
+ }
610
+ else {
611
+ i = this.#prev[i];
612
+ }
613
+ }
614
+ }
615
+ }
616
+ *#rindexes({ allowStale = this.allowStale } = {}) {
617
+ if (this.#size) {
618
+ for (let i = this.#head; true;) {
619
+ if (!this.#isValidIndex(i)) {
620
+ break;
621
+ }
622
+ if (allowStale || !this.#isStale(i)) {
623
+ yield i;
624
+ }
625
+ if (i === this.#tail) {
626
+ break;
627
+ }
628
+ else {
629
+ i = this.#next[i];
630
+ }
631
+ }
632
+ }
633
+ }
634
+ #isValidIndex(index) {
635
+ return (index !== undefined &&
636
+ this.#keyMap.get(this.#keyList[index]) === index);
637
+ }
638
+ /**
639
+ * Return a generator yielding `[key, value]` pairs,
640
+ * in order from most recently used to least recently used.
641
+ */
642
+ *entries() {
643
+ for (const i of this.#indexes()) {
644
+ if (this.#valList[i] !== undefined &&
645
+ this.#keyList[i] !== undefined &&
646
+ !this.#isBackgroundFetch(this.#valList[i])) {
647
+ yield [this.#keyList[i], this.#valList[i]];
648
+ }
649
+ }
650
+ }
651
+ /**
652
+ * Inverse order version of {@link LRUCache.entries}
653
+ *
654
+ * Return a generator yielding `[key, value]` pairs,
655
+ * in order from least recently used to most recently used.
656
+ */
657
+ *rentries() {
658
+ for (const i of this.#rindexes()) {
659
+ if (this.#valList[i] !== undefined &&
660
+ this.#keyList[i] !== undefined &&
661
+ !this.#isBackgroundFetch(this.#valList[i])) {
662
+ yield [this.#keyList[i], this.#valList[i]];
663
+ }
664
+ }
665
+ }
666
+ /**
667
+ * Return a generator yielding the keys in the cache,
668
+ * in order from most recently used to least recently used.
669
+ */
670
+ *keys() {
671
+ for (const i of this.#indexes()) {
672
+ const k = this.#keyList[i];
673
+ if (k !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
674
+ yield k;
675
+ }
676
+ }
677
+ }
678
+ /**
679
+ * Inverse order version of {@link LRUCache.keys}
680
+ *
681
+ * Return a generator yielding the keys in the cache,
682
+ * in order from least recently used to most recently used.
683
+ */
684
+ *rkeys() {
685
+ for (const i of this.#rindexes()) {
686
+ const k = this.#keyList[i];
687
+ if (k !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
688
+ yield k;
689
+ }
690
+ }
691
+ }
692
+ /**
693
+ * Return a generator yielding the values in the cache,
694
+ * in order from most recently used to least recently used.
695
+ */
696
+ *values() {
697
+ for (const i of this.#indexes()) {
698
+ const v = this.#valList[i];
699
+ if (v !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
700
+ yield this.#valList[i];
701
+ }
702
+ }
703
+ }
704
+ /**
705
+ * Inverse order version of {@link LRUCache.values}
706
+ *
707
+ * Return a generator yielding the values in the cache,
708
+ * in order from least recently used to most recently used.
709
+ */
710
+ *rvalues() {
711
+ for (const i of this.#rindexes()) {
712
+ const v = this.#valList[i];
713
+ if (v !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
714
+ yield this.#valList[i];
715
+ }
716
+ }
717
+ }
718
+ /**
719
+ * Iterating over the cache itself yields the same results as
720
+ * {@link LRUCache.entries}
721
+ */
722
+ [Symbol.iterator]() {
723
+ return this.entries();
724
+ }
725
+ /**
726
+ * A String value that is used in the creation of the default string
727
+ * description of an object. Called by the built-in method
728
+ * `Object.prototype.toString`.
729
+ */
730
+ [Symbol.toStringTag] = 'LRUCache';
731
+ /**
732
+ * Find a value for which the supplied fn method returns a truthy value,
733
+ * similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
734
+ */
735
+ find(fn, getOptions = {}) {
736
+ for (const i of this.#indexes()) {
737
+ const v = this.#valList[i];
738
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
739
+ if (value === undefined)
740
+ continue;
741
+ if (fn(value, this.#keyList[i], this)) {
742
+ return this.get(this.#keyList[i], getOptions);
743
+ }
744
+ }
745
+ }
746
+ /**
747
+ * Call the supplied function on each item in the cache, in order from most
748
+ * recently used to least recently used.
749
+ *
750
+ * `fn` is called as `fn(value, key, cache)`.
751
+ *
752
+ * If `thisp` is provided, function will be called in the `this`-context of
753
+ * the provided object, or the cache if no `thisp` object is provided.
754
+ *
755
+ * Does not update age or recenty of use, or iterate over stale values.
756
+ */
757
+ forEach(fn, thisp = this) {
758
+ for (const i of this.#indexes()) {
759
+ const v = this.#valList[i];
760
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
761
+ if (value === undefined)
762
+ continue;
763
+ fn.call(thisp, value, this.#keyList[i], this);
764
+ }
765
+ }
766
+ /**
767
+ * The same as {@link LRUCache.forEach} but items are iterated over in
768
+ * reverse order. (ie, less recently used items are iterated over first.)
769
+ */
770
+ rforEach(fn, thisp = this) {
771
+ for (const i of this.#rindexes()) {
772
+ const v = this.#valList[i];
773
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
774
+ if (value === undefined)
775
+ continue;
776
+ fn.call(thisp, value, this.#keyList[i], this);
777
+ }
778
+ }
779
+ /**
780
+ * Delete any stale entries. Returns true if anything was removed,
781
+ * false otherwise.
782
+ */
783
+ purgeStale() {
784
+ let deleted = false;
785
+ for (const i of this.#rindexes({ allowStale: true })) {
786
+ if (this.#isStale(i)) {
787
+ this.#delete(this.#keyList[i], 'expire');
788
+ deleted = true;
789
+ }
790
+ }
791
+ return deleted;
792
+ }
793
+ /**
794
+ * Get the extended info about a given entry, to get its value, size, and
795
+ * TTL info simultaneously. Returns `undefined` if the key is not present.
796
+ *
797
+ * Unlike {@link LRUCache#dump}, which is designed to be portable and survive
798
+ * serialization, the `start` value is always the current timestamp, and the
799
+ * `ttl` is a calculated remaining time to live (negative if expired).
800
+ *
801
+ * Always returns stale values, if their info is found in the cache, so be
802
+ * sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
803
+ * if relevant.
804
+ */
805
+ info(key) {
806
+ const i = this.#keyMap.get(key);
807
+ if (i === undefined)
808
+ return undefined;
809
+ const v = this.#valList[i];
810
+ /* c8 ignore start - this isn't tested for the info function,
811
+ * but it's the same logic as found in other places. */
812
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
813
+ if (value === undefined)
814
+ return undefined;
815
+ /* c8 ignore end */
816
+ const entry = { value };
817
+ if (this.#ttls && this.#starts) {
818
+ const ttl = this.#ttls[i];
819
+ const start = this.#starts[i];
820
+ if (ttl && start) {
821
+ const remain = ttl - (this.#perf.now() - start);
822
+ entry.ttl = remain;
823
+ entry.start = Date.now();
824
+ }
825
+ }
826
+ if (this.#sizes) {
827
+ entry.size = this.#sizes[i];
828
+ }
829
+ return entry;
830
+ }
831
+ /**
832
+ * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
833
+ * passed to {@link LRUCache#load}.
834
+ *
835
+ * The `start` fields are calculated relative to a portable `Date.now()`
836
+ * timestamp, even if `performance.now()` is available.
837
+ *
838
+ * Stale entries are always included in the `dump`, even if
839
+ * {@link LRUCache.OptionsBase.allowStale} is false.
840
+ *
841
+ * Note: this returns an actual array, not a generator, so it can be more
842
+ * easily passed around.
843
+ */
844
+ dump() {
845
+ const arr = [];
846
+ for (const i of this.#indexes({ allowStale: true })) {
847
+ const key = this.#keyList[i];
848
+ const v = this.#valList[i];
849
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
850
+ if (value === undefined || key === undefined)
851
+ continue;
852
+ const entry = { value };
853
+ if (this.#ttls && this.#starts) {
854
+ entry.ttl = this.#ttls[i];
855
+ // always dump the start relative to a portable timestamp
856
+ // it's ok for this to be a bit slow, it's a rare operation.
857
+ const age = this.#perf.now() - this.#starts[i];
858
+ entry.start = Math.floor(Date.now() - age);
859
+ }
860
+ if (this.#sizes) {
861
+ entry.size = this.#sizes[i];
862
+ }
863
+ arr.unshift([key, entry]);
864
+ }
865
+ return arr;
866
+ }
867
+ /**
868
+ * Reset the cache and load in the items in entries in the order listed.
869
+ *
870
+ * The shape of the resulting cache may be different if the same options are
871
+ * not used in both caches.
872
+ *
873
+ * The `start` fields are assumed to be calculated relative to a portable
874
+ * `Date.now()` timestamp, even if `performance.now()` is available.
875
+ */
876
+ load(arr) {
877
+ this.clear();
878
+ for (const [key, entry] of arr) {
879
+ if (entry.start) {
880
+ // entry.start is a portable timestamp, but we may be using
881
+ // node's performance.now(), so calculate the offset, so that
882
+ // we get the intended remaining TTL, no matter how long it's
883
+ // been on ice.
884
+ //
885
+ // it's ok for this to be a bit slow, it's a rare operation.
886
+ const age = Date.now() - entry.start;
887
+ entry.start = this.#perf.now() - age;
888
+ }
889
+ this.set(key, entry.value, entry);
890
+ }
891
+ }
892
+ /**
893
+ * Add a value to the cache.
894
+ *
895
+ * Note: if `undefined` is specified as a value, this is an alias for
896
+ * {@link LRUCache#delete}
897
+ *
898
+ * Fields on the {@link LRUCache.SetOptions} options param will override
899
+ * their corresponding values in the constructor options for the scope
900
+ * of this single `set()` operation.
901
+ *
902
+ * If `start` is provided, then that will set the effective start
903
+ * time for the TTL calculation. Note that this must be a previous
904
+ * value of `performance.now()` if supported, or a previous value of
905
+ * `Date.now()` if not.
906
+ *
907
+ * Options object may also include `size`, which will prevent
908
+ * calling the `sizeCalculation` function and just use the specified
909
+ * number if it is a positive integer, and `noDisposeOnSet` which
910
+ * will prevent calling a `dispose` function in the case of
911
+ * overwrites.
912
+ *
913
+ * If the `size` (or return value of `sizeCalculation`) for a given
914
+ * entry is greater than `maxEntrySize`, then the item will not be
915
+ * added to the cache.
916
+ *
917
+ * Will update the recency of the entry.
918
+ *
919
+ * If the value is `undefined`, then this is an alias for
920
+ * `cache.delete(key)`. `undefined` is never stored in the cache.
921
+ */
922
+ set(k, v, setOptions = {}) {
923
+ if (v === undefined) {
924
+ this.delete(k);
925
+ return this;
926
+ }
927
+ const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status, } = setOptions;
928
+ let { noUpdateTTL = this.noUpdateTTL } = setOptions;
929
+ const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation);
930
+ // if the item doesn't fit, don't do anything
931
+ // NB: maxEntrySize set to maxSize by default
932
+ if (this.maxEntrySize && size > this.maxEntrySize) {
933
+ if (status) {
934
+ status.set = 'miss';
935
+ status.maxEntrySizeExceeded = true;
936
+ }
937
+ // have to delete, in case something is there already.
938
+ this.#delete(k, 'set');
939
+ return this;
940
+ }
941
+ let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
942
+ if (index === undefined) {
943
+ // addition
944
+ index = (this.#size === 0 ? this.#tail
945
+ : this.#free.length !== 0 ? this.#free.pop()
946
+ : this.#size === this.#max ? this.#evict(false)
947
+ : this.#size);
948
+ this.#keyList[index] = k;
949
+ this.#valList[index] = v;
950
+ this.#keyMap.set(k, index);
951
+ this.#next[this.#tail] = index;
952
+ this.#prev[index] = this.#tail;
953
+ this.#tail = index;
954
+ this.#size++;
955
+ this.#addItemSize(index, size, status);
956
+ if (status)
957
+ status.set = 'add';
958
+ noUpdateTTL = false;
959
+ if (this.#hasOnInsert) {
960
+ this.#onInsert?.(v, k, 'add');
961
+ }
962
+ }
963
+ else {
964
+ // update
965
+ this.#moveToTail(index);
966
+ const oldVal = this.#valList[index];
967
+ if (v !== oldVal) {
968
+ if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
969
+ oldVal.__abortController.abort(new Error('replaced'));
970
+ const { __staleWhileFetching: s } = oldVal;
971
+ if (s !== undefined && !noDisposeOnSet) {
972
+ if (this.#hasDispose) {
973
+ this.#dispose?.(s, k, 'set');
974
+ }
975
+ if (this.#hasDisposeAfter) {
976
+ this.#disposed?.push([s, k, 'set']);
977
+ }
978
+ }
979
+ }
980
+ else if (!noDisposeOnSet) {
981
+ if (this.#hasDispose) {
982
+ this.#dispose?.(oldVal, k, 'set');
983
+ }
984
+ if (this.#hasDisposeAfter) {
985
+ this.#disposed?.push([oldVal, k, 'set']);
986
+ }
987
+ }
988
+ this.#removeItemSize(index);
989
+ this.#addItemSize(index, size, status);
990
+ this.#valList[index] = v;
991
+ if (status) {
992
+ status.set = 'replace';
993
+ const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ?
994
+ oldVal.__staleWhileFetching
995
+ : oldVal;
996
+ if (oldValue !== undefined)
997
+ status.oldValue = oldValue;
998
+ }
999
+ }
1000
+ else if (status) {
1001
+ status.set = 'update';
1002
+ }
1003
+ if (this.#hasOnInsert) {
1004
+ this.onInsert?.(v, k, v === oldVal ? 'update' : 'replace');
1005
+ }
1006
+ }
1007
+ if (ttl !== 0 && !this.#ttls) {
1008
+ this.#initializeTTLTracking();
1009
+ }
1010
+ if (this.#ttls) {
1011
+ if (!noUpdateTTL) {
1012
+ this.#setItemTTL(index, ttl, start);
1013
+ }
1014
+ if (status)
1015
+ this.#statusTTL(status, index);
1016
+ }
1017
+ if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
1018
+ const dt = this.#disposed;
1019
+ let task;
1020
+ while ((task = dt?.shift())) {
1021
+ this.#disposeAfter?.(...task);
1022
+ }
1023
+ }
1024
+ return this;
1025
+ }
1026
+ /**
1027
+ * Evict the least recently used item, returning its value or
1028
+ * `undefined` if cache is empty.
1029
+ */
1030
+ pop() {
1031
+ try {
1032
+ while (this.#size) {
1033
+ const val = this.#valList[this.#head];
1034
+ this.#evict(true);
1035
+ if (this.#isBackgroundFetch(val)) {
1036
+ if (val.__staleWhileFetching) {
1037
+ return val.__staleWhileFetching;
1038
+ }
1039
+ }
1040
+ else if (val !== undefined) {
1041
+ return val;
1042
+ }
1043
+ }
1044
+ }
1045
+ finally {
1046
+ if (this.#hasDisposeAfter && this.#disposed) {
1047
+ const dt = this.#disposed;
1048
+ let task;
1049
+ while ((task = dt?.shift())) {
1050
+ this.#disposeAfter?.(...task);
1051
+ }
1052
+ }
1053
+ }
1054
+ }
1055
+ #evict(free) {
1056
+ const head = this.#head;
1057
+ const k = this.#keyList[head];
1058
+ const v = this.#valList[head];
1059
+ if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) {
1060
+ v.__abortController.abort(new Error('evicted'));
1061
+ }
1062
+ else if (this.#hasDispose || this.#hasDisposeAfter) {
1063
+ if (this.#hasDispose) {
1064
+ this.#dispose?.(v, k, 'evict');
1065
+ }
1066
+ if (this.#hasDisposeAfter) {
1067
+ this.#disposed?.push([v, k, 'evict']);
1068
+ }
1069
+ }
1070
+ this.#removeItemSize(head);
1071
+ if (this.#autopurgeTimers?.[head]) {
1072
+ clearTimeout(this.#autopurgeTimers[head]);
1073
+ this.#autopurgeTimers[head] = undefined;
1074
+ }
1075
+ // if we aren't about to use the index, then null these out
1076
+ if (free) {
1077
+ this.#keyList[head] = undefined;
1078
+ this.#valList[head] = undefined;
1079
+ this.#free.push(head);
1080
+ }
1081
+ if (this.#size === 1) {
1082
+ this.#head = this.#tail = 0;
1083
+ this.#free.length = 0;
1084
+ }
1085
+ else {
1086
+ this.#head = this.#next[head];
1087
+ }
1088
+ this.#keyMap.delete(k);
1089
+ this.#size--;
1090
+ return head;
1091
+ }
1092
+ /**
1093
+ * Check if a key is in the cache, without updating the recency of use.
1094
+ * Will return false if the item is stale, even though it is technically
1095
+ * in the cache.
1096
+ *
1097
+ * Check if a key is in the cache, without updating the recency of
1098
+ * use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
1099
+ * to `true` in either the options or the constructor.
1100
+ *
1101
+ * Will return `false` if the item is stale, even though it is technically in
1102
+ * the cache. The difference can be determined (if it matters) by using a
1103
+ * `status` argument, and inspecting the `has` field.
1104
+ *
1105
+ * Will not update item age unless
1106
+ * {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
1107
+ */
1108
+ has(k, hasOptions = {}) {
1109
+ const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
1110
+ const index = this.#keyMap.get(k);
1111
+ if (index !== undefined) {
1112
+ const v = this.#valList[index];
1113
+ if (this.#isBackgroundFetch(v) &&
1114
+ v.__staleWhileFetching === undefined) {
1115
+ return false;
1116
+ }
1117
+ if (!this.#isStale(index)) {
1118
+ if (updateAgeOnHas) {
1119
+ this.#updateItemAge(index);
1120
+ }
1121
+ if (status) {
1122
+ status.has = 'hit';
1123
+ this.#statusTTL(status, index);
1124
+ }
1125
+ return true;
1126
+ }
1127
+ else if (status) {
1128
+ status.has = 'stale';
1129
+ this.#statusTTL(status, index);
1130
+ }
1131
+ }
1132
+ else if (status) {
1133
+ status.has = 'miss';
1134
+ }
1135
+ return false;
1136
+ }
1137
+ /**
1138
+ * Like {@link LRUCache#get} but doesn't update recency or delete stale
1139
+ * items.
1140
+ *
1141
+ * Returns `undefined` if the item is stale, unless
1142
+ * {@link LRUCache.OptionsBase.allowStale} is set.
1143
+ */
1144
+ peek(k, peekOptions = {}) {
1145
+ const { allowStale = this.allowStale } = peekOptions;
1146
+ const index = this.#keyMap.get(k);
1147
+ if (index === undefined || (!allowStale && this.#isStale(index))) {
1148
+ return;
1149
+ }
1150
+ const v = this.#valList[index];
1151
+ // either stale and allowed, or forcing a refresh of non-stale value
1152
+ return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
1153
+ }
1154
+ #backgroundFetch(k, index, options, context) {
1155
+ const v = index === undefined ? undefined : this.#valList[index];
1156
+ if (this.#isBackgroundFetch(v)) {
1157
+ return v;
1158
+ }
1159
+ const ac = new AC();
1160
+ const { signal } = options;
1161
+ // when/if our AC signals, then stop listening to theirs.
1162
+ signal?.addEventListener('abort', () => ac.abort(signal.reason), {
1163
+ signal: ac.signal,
1164
+ });
1165
+ const fetchOpts = {
1166
+ signal: ac.signal,
1167
+ options,
1168
+ context,
1169
+ };
1170
+ const cb = (v, updateCache = false) => {
1171
+ const { aborted } = ac.signal;
1172
+ const ignoreAbort = options.ignoreFetchAbort && v !== undefined;
1173
+ const proceed = options.ignoreFetchAbort ||
1174
+ !!(options.allowStaleOnFetchAbort && v !== undefined);
1175
+ if (options.status) {
1176
+ if (aborted && !updateCache) {
1177
+ options.status.fetchAborted = true;
1178
+ options.status.fetchError = ac.signal.reason;
1179
+ if (ignoreAbort)
1180
+ options.status.fetchAbortIgnored = true;
1181
+ }
1182
+ else {
1183
+ options.status.fetchResolved = true;
1184
+ }
1185
+ }
1186
+ if (aborted && !ignoreAbort && !updateCache) {
1187
+ return fetchFail(ac.signal.reason, proceed);
1188
+ }
1189
+ // either we didn't abort, and are still here, or we did, and ignored
1190
+ const bf = p;
1191
+ // if nothing else has been written there but we're set to update the
1192
+ // cache and ignore the abort, or if it's still pending on this specific
1193
+ // background request, then write it to the cache.
1194
+ const vl = this.#valList[index];
1195
+ if (vl === p || (ignoreAbort && updateCache && vl === undefined)) {
1196
+ if (v === undefined) {
1197
+ if (bf.__staleWhileFetching !== undefined) {
1198
+ this.#valList[index] = bf.__staleWhileFetching;
1199
+ }
1200
+ else {
1201
+ this.#delete(k, 'fetch');
1202
+ }
1203
+ }
1204
+ else {
1205
+ if (options.status)
1206
+ options.status.fetchUpdated = true;
1207
+ this.set(k, v, fetchOpts.options);
1208
+ }
1209
+ }
1210
+ return v;
1211
+ };
1212
+ const eb = (er) => {
1213
+ if (options.status) {
1214
+ options.status.fetchRejected = true;
1215
+ options.status.fetchError = er;
1216
+ }
1217
+ // do not pass go, do not collect $200
1218
+ return fetchFail(er, false);
1219
+ };
1220
+ const fetchFail = (er, proceed) => {
1221
+ const { aborted } = ac.signal;
1222
+ const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
1223
+ const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
1224
+ const noDelete = allowStale || options.noDeleteOnFetchRejection;
1225
+ const bf = p;
1226
+ if (this.#valList[index] === p) {
1227
+ // if we allow stale on fetch rejections, then we need to ensure that
1228
+ // the stale value is not removed from the cache when the fetch fails.
1229
+ const del = !noDelete || (!proceed && bf.__staleWhileFetching === undefined);
1230
+ if (del) {
1231
+ this.#delete(k, 'fetch');
1232
+ }
1233
+ else if (!allowStaleAborted) {
1234
+ // still replace the *promise* with the stale value,
1235
+ // since we are done with the promise at this point.
1236
+ // leave it untouched if we're still waiting for an
1237
+ // aborted background fetch that hasn't yet returned.
1238
+ this.#valList[index] = bf.__staleWhileFetching;
1239
+ }
1240
+ }
1241
+ if (allowStale) {
1242
+ if (options.status && bf.__staleWhileFetching !== undefined) {
1243
+ options.status.returnedStale = true;
1244
+ }
1245
+ return bf.__staleWhileFetching;
1246
+ }
1247
+ else if (bf.__returned === bf) {
1248
+ throw er;
1249
+ }
1250
+ };
1251
+ const pcall = (res, rej) => {
1252
+ const fmp = this.#fetchMethod?.(k, v, fetchOpts);
1253
+ if (fmp && fmp instanceof Promise) {
1254
+ fmp.then(v => res(v === undefined ? undefined : v), rej);
1255
+ }
1256
+ // ignored, we go until we finish, regardless.
1257
+ // defer check until we are actually aborting,
1258
+ // so fetchMethod can override.
1259
+ ac.signal.addEventListener('abort', () => {
1260
+ if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
1261
+ res(undefined);
1262
+ // when it eventually resolves, update the cache.
1263
+ if (options.allowStaleOnFetchAbort) {
1264
+ res = v => cb(v, true);
1265
+ }
1266
+ }
1267
+ });
1268
+ };
1269
+ if (options.status)
1270
+ options.status.fetchDispatched = true;
1271
+ const p = new Promise(pcall).then(cb, eb);
1272
+ const bf = Object.assign(p, {
1273
+ __abortController: ac,
1274
+ __staleWhileFetching: v,
1275
+ __returned: undefined,
1276
+ });
1277
+ if (index === undefined) {
1278
+ // internal, don't expose status.
1279
+ this.set(k, bf, { ...fetchOpts.options, status: undefined });
1280
+ index = this.#keyMap.get(k);
1281
+ }
1282
+ else {
1283
+ this.#valList[index] = bf;
1284
+ }
1285
+ return bf;
1286
+ }
1287
+ #isBackgroundFetch(p) {
1288
+ if (!this.#hasFetchMethod)
1289
+ return false;
1290
+ const b = p;
1291
+ return (!!b &&
1292
+ b instanceof Promise &&
1293
+ b.hasOwnProperty('__staleWhileFetching') &&
1294
+ b.__abortController instanceof AC);
1295
+ }
1296
+ async fetch(k, fetchOptions = {}) {
1297
+ const {
1298
+ // get options
1299
+ allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet,
1300
+ // set options
1301
+ ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL,
1302
+ // fetch exclusive options
1303
+ noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal, } = fetchOptions;
1304
+ if (!this.#hasFetchMethod) {
1305
+ if (status)
1306
+ status.fetch = 'get';
1307
+ return this.get(k, {
1308
+ allowStale,
1309
+ updateAgeOnGet,
1310
+ noDeleteOnStaleGet,
1311
+ status,
1312
+ });
1313
+ }
1314
+ const options = {
1315
+ allowStale,
1316
+ updateAgeOnGet,
1317
+ noDeleteOnStaleGet,
1318
+ ttl,
1319
+ noDisposeOnSet,
1320
+ size,
1321
+ sizeCalculation,
1322
+ noUpdateTTL,
1323
+ noDeleteOnFetchRejection,
1324
+ allowStaleOnFetchRejection,
1325
+ allowStaleOnFetchAbort,
1326
+ ignoreFetchAbort,
1327
+ status,
1328
+ signal,
1329
+ };
1330
+ let index = this.#keyMap.get(k);
1331
+ if (index === undefined) {
1332
+ if (status)
1333
+ status.fetch = 'miss';
1334
+ const p = this.#backgroundFetch(k, index, options, context);
1335
+ return (p.__returned = p);
1336
+ }
1337
+ else {
1338
+ // in cache, maybe already fetching
1339
+ const v = this.#valList[index];
1340
+ if (this.#isBackgroundFetch(v)) {
1341
+ const stale = allowStale && v.__staleWhileFetching !== undefined;
1342
+ if (status) {
1343
+ status.fetch = 'inflight';
1344
+ if (stale)
1345
+ status.returnedStale = true;
1346
+ }
1347
+ return stale ? v.__staleWhileFetching : (v.__returned = v);
1348
+ }
1349
+ // if we force a refresh, that means do NOT serve the cached value,
1350
+ // unless we are already in the process of refreshing the cache.
1351
+ const isStale = this.#isStale(index);
1352
+ if (!forceRefresh && !isStale) {
1353
+ if (status)
1354
+ status.fetch = 'hit';
1355
+ this.#moveToTail(index);
1356
+ if (updateAgeOnGet) {
1357
+ this.#updateItemAge(index);
1358
+ }
1359
+ if (status)
1360
+ this.#statusTTL(status, index);
1361
+ return v;
1362
+ }
1363
+ // ok, it is stale or a forced refresh, and not already fetching.
1364
+ // refresh the cache.
1365
+ const p = this.#backgroundFetch(k, index, options, context);
1366
+ const hasStale = p.__staleWhileFetching !== undefined;
1367
+ const staleVal = hasStale && allowStale;
1368
+ if (status) {
1369
+ status.fetch = isStale ? 'stale' : 'refresh';
1370
+ if (staleVal && isStale)
1371
+ status.returnedStale = true;
1372
+ }
1373
+ return staleVal ? p.__staleWhileFetching : (p.__returned = p);
1374
+ }
1375
+ }
1376
+ async forceFetch(k, fetchOptions = {}) {
1377
+ const v = await this.fetch(k, fetchOptions);
1378
+ if (v === undefined)
1379
+ throw new Error('fetch() returned undefined');
1380
+ return v;
1381
+ }
1382
+ memo(k, memoOptions = {}) {
1383
+ const memoMethod = this.#memoMethod;
1384
+ if (!memoMethod) {
1385
+ throw new Error('no memoMethod provided to constructor');
1386
+ }
1387
+ const { context, forceRefresh, ...options } = memoOptions;
1388
+ const v = this.get(k, options);
1389
+ if (!forceRefresh && v !== undefined)
1390
+ return v;
1391
+ const vv = memoMethod(k, v, {
1392
+ options,
1393
+ context,
1394
+ });
1395
+ this.set(k, vv, options);
1396
+ return vv;
1397
+ }
1398
+ /**
1399
+ * Return a value from the cache. Will update the recency of the cache
1400
+ * entry found.
1401
+ *
1402
+ * If the key is not found, get() will return `undefined`.
1403
+ */
1404
+ get(k, getOptions = {}) {
1405
+ const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status, } = getOptions;
1406
+ const index = this.#keyMap.get(k);
1407
+ if (index !== undefined) {
1408
+ const value = this.#valList[index];
1409
+ const fetching = this.#isBackgroundFetch(value);
1410
+ if (status)
1411
+ this.#statusTTL(status, index);
1412
+ if (this.#isStale(index)) {
1413
+ if (status)
1414
+ status.get = 'stale';
1415
+ // delete only if not an in-flight background fetch
1416
+ if (!fetching) {
1417
+ if (!noDeleteOnStaleGet) {
1418
+ this.#delete(k, 'expire');
1419
+ }
1420
+ if (status && allowStale)
1421
+ status.returnedStale = true;
1422
+ return allowStale ? value : undefined;
1423
+ }
1424
+ else {
1425
+ if (status &&
1426
+ allowStale &&
1427
+ value.__staleWhileFetching !== undefined) {
1428
+ status.returnedStale = true;
1429
+ }
1430
+ return allowStale ? value.__staleWhileFetching : undefined;
1431
+ }
1432
+ }
1433
+ else {
1434
+ if (status)
1435
+ status.get = 'hit';
1436
+ // if we're currently fetching it, we don't actually have it yet
1437
+ // it's not stale, which means this isn't a staleWhileRefetching.
1438
+ // If it's not stale, and fetching, AND has a __staleWhileFetching
1439
+ // value, then that means the user fetched with {forceRefresh:true},
1440
+ // so it's safe to return that value.
1441
+ if (fetching) {
1442
+ return value.__staleWhileFetching;
1443
+ }
1444
+ this.#moveToTail(index);
1445
+ if (updateAgeOnGet) {
1446
+ this.#updateItemAge(index);
1447
+ }
1448
+ return value;
1449
+ }
1450
+ }
1451
+ else if (status) {
1452
+ status.get = 'miss';
1453
+ }
1454
+ }
1455
+ #connect(p, n) {
1456
+ this.#prev[n] = p;
1457
+ this.#next[p] = n;
1458
+ }
1459
+ #moveToTail(index) {
1460
+ // if tail already, nothing to do
1461
+ // if head, move head to next[index]
1462
+ // else
1463
+ // move next[prev[index]] to next[index] (head has no prev)
1464
+ // move prev[next[index]] to prev[index]
1465
+ // prev[index] = tail
1466
+ // next[tail] = index
1467
+ // tail = index
1468
+ if (index !== this.#tail) {
1469
+ if (index === this.#head) {
1470
+ this.#head = this.#next[index];
1471
+ }
1472
+ else {
1473
+ this.#connect(this.#prev[index], this.#next[index]);
1474
+ }
1475
+ this.#connect(this.#tail, index);
1476
+ this.#tail = index;
1477
+ }
1478
+ }
1479
+ /**
1480
+ * Deletes a key out of the cache.
1481
+ *
1482
+ * Returns true if the key was deleted, false otherwise.
1483
+ */
1484
+ delete(k) {
1485
+ return this.#delete(k, 'delete');
1486
+ }
1487
+ #delete(k, reason) {
1488
+ let deleted = false;
1489
+ if (this.#size !== 0) {
1490
+ const index = this.#keyMap.get(k);
1491
+ if (index !== undefined) {
1492
+ if (this.#autopurgeTimers?.[index]) {
1493
+ clearTimeout(this.#autopurgeTimers?.[index]);
1494
+ this.#autopurgeTimers[index] = undefined;
1495
+ }
1496
+ deleted = true;
1497
+ if (this.#size === 1) {
1498
+ this.#clear(reason);
1499
+ }
1500
+ else {
1501
+ this.#removeItemSize(index);
1502
+ const v = this.#valList[index];
1503
+ if (this.#isBackgroundFetch(v)) {
1504
+ v.__abortController.abort(new Error('deleted'));
1505
+ }
1506
+ else if (this.#hasDispose || this.#hasDisposeAfter) {
1507
+ if (this.#hasDispose) {
1508
+ this.#dispose?.(v, k, reason);
1509
+ }
1510
+ if (this.#hasDisposeAfter) {
1511
+ this.#disposed?.push([v, k, reason]);
1512
+ }
1513
+ }
1514
+ this.#keyMap.delete(k);
1515
+ this.#keyList[index] = undefined;
1516
+ this.#valList[index] = undefined;
1517
+ if (index === this.#tail) {
1518
+ this.#tail = this.#prev[index];
1519
+ }
1520
+ else if (index === this.#head) {
1521
+ this.#head = this.#next[index];
1522
+ }
1523
+ else {
1524
+ const pi = this.#prev[index];
1525
+ this.#next[pi] = this.#next[index];
1526
+ const ni = this.#next[index];
1527
+ this.#prev[ni] = this.#prev[index];
1528
+ }
1529
+ this.#size--;
1530
+ this.#free.push(index);
1531
+ }
1532
+ }
1533
+ }
1534
+ if (this.#hasDisposeAfter && this.#disposed?.length) {
1535
+ const dt = this.#disposed;
1536
+ let task;
1537
+ while ((task = dt?.shift())) {
1538
+ this.#disposeAfter?.(...task);
1539
+ }
1540
+ }
1541
+ return deleted;
1542
+ }
1543
+ /**
1544
+ * Clear the cache entirely, throwing away all values.
1545
+ */
1546
+ clear() {
1547
+ return this.#clear('delete');
1548
+ }
1549
+ #clear(reason) {
1550
+ for (const index of this.#rindexes({ allowStale: true })) {
1551
+ const v = this.#valList[index];
1552
+ if (this.#isBackgroundFetch(v)) {
1553
+ v.__abortController.abort(new Error('deleted'));
1554
+ }
1555
+ else {
1556
+ const k = this.#keyList[index];
1557
+ if (this.#hasDispose) {
1558
+ this.#dispose?.(v, k, reason);
1559
+ }
1560
+ if (this.#hasDisposeAfter) {
1561
+ this.#disposed?.push([v, k, reason]);
1562
+ }
1563
+ }
1564
+ }
1565
+ this.#keyMap.clear();
1566
+ this.#valList.fill(undefined);
1567
+ this.#keyList.fill(undefined);
1568
+ if (this.#ttls && this.#starts) {
1569
+ this.#ttls.fill(0);
1570
+ this.#starts.fill(0);
1571
+ for (const t of this.#autopurgeTimers ?? []) {
1572
+ if (t !== undefined)
1573
+ clearTimeout(t);
1574
+ }
1575
+ this.#autopurgeTimers?.fill(undefined);
1576
+ }
1577
+ if (this.#sizes) {
1578
+ this.#sizes.fill(0);
1579
+ }
1580
+ this.#head = 0;
1581
+ this.#tail = 0;
1582
+ this.#free.length = 0;
1583
+ this.#calculatedSize = 0;
1584
+ this.#size = 0;
1585
+ if (this.#hasDisposeAfter && this.#disposed) {
1586
+ const dt = this.#disposed;
1587
+ let task;
1588
+ while ((task = dt?.shift())) {
1589
+ this.#disposeAfter?.(...task);
1590
+ }
1591
+ }
1592
+ }
1593
+ }
1594
+ exports.LRUCache = LRUCache;
1595
+ //# sourceMappingURL=index.js.map