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