@pnpm/exe 11.0.0-alpha.9 → 11.0.0-beta.1

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 (219) hide show
  1. package/dist/node_modules/@gar/promise-retry/lib/index.js +28 -0
  2. package/dist/node_modules/@gar/promise-retry/package.json +48 -0
  3. package/dist/node_modules/@npmcli/agent/package.json +7 -7
  4. package/dist/node_modules/@npmcli/fs/package.json +4 -4
  5. package/dist/node_modules/abbrev/package.json +11 -15
  6. package/dist/node_modules/balanced-match/package.json +4 -7
  7. package/dist/node_modules/brace-expansion/dist/commonjs/index.js +1 -1
  8. package/dist/node_modules/brace-expansion/dist/esm/index.js +1 -1
  9. package/dist/node_modules/brace-expansion/package.json +3 -3
  10. package/dist/node_modules/cacache/package.json +10 -11
  11. package/dist/node_modules/glob/dist/commonjs/glob.js +2 -1
  12. package/dist/node_modules/glob/dist/commonjs/index.min.js +4 -0
  13. package/dist/node_modules/glob/dist/commonjs/pattern.js +4 -0
  14. package/dist/node_modules/glob/dist/esm/glob.js +2 -1
  15. package/dist/node_modules/glob/dist/esm/index.min.js +4 -0
  16. package/dist/node_modules/glob/dist/esm/pattern.js +4 -0
  17. package/dist/node_modules/glob/package.json +38 -37
  18. package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +460 -525
  19. package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +179 -182
  20. package/dist/node_modules/iconv-lite/encodings/index.js +15 -15
  21. package/dist/node_modules/iconv-lite/encodings/internal.js +168 -148
  22. package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +55 -52
  23. package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +174 -175
  24. package/dist/node_modules/iconv-lite/encodings/utf16.js +121 -131
  25. package/dist/node_modules/iconv-lite/encodings/utf32.js +226 -238
  26. package/dist/node_modules/iconv-lite/encodings/utf7.js +208 -215
  27. package/dist/node_modules/iconv-lite/lib/bom-handling.js +30 -34
  28. package/dist/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
  29. package/dist/node_modules/iconv-lite/lib/index.js +125 -123
  30. package/dist/node_modules/iconv-lite/lib/streams.js +92 -96
  31. package/dist/node_modules/iconv-lite/package.json +34 -8
  32. package/dist/node_modules/isexe/package.json +65 -18
  33. package/dist/node_modules/lru-cache/dist/commonjs/index.js +134 -85
  34. package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
  35. package/dist/node_modules/lru-cache/dist/esm/index.js +134 -85
  36. package/dist/node_modules/lru-cache/dist/esm/index.min.js +1 -1
  37. package/dist/node_modules/lru-cache/package.json +18 -41
  38. package/dist/node_modules/make-fetch-happen/lib/remote.js +1 -1
  39. package/dist/node_modules/make-fetch-happen/package.json +10 -10
  40. package/dist/node_modules/minimatch/dist/commonjs/ast.js +266 -21
  41. package/dist/node_modules/minimatch/dist/commonjs/index.js +178 -92
  42. package/dist/node_modules/minimatch/dist/esm/ast.js +266 -21
  43. package/dist/node_modules/minimatch/dist/esm/index.js +178 -92
  44. package/dist/node_modules/minimatch/package.json +4 -4
  45. package/dist/node_modules/minipass/dist/commonjs/index.js +13 -3
  46. package/dist/node_modules/minipass/dist/esm/index.js +3 -1
  47. package/dist/node_modules/minipass/package.json +9 -14
  48. package/dist/node_modules/minipass-fetch/lib/body.js +25 -15
  49. package/dist/node_modules/minipass-fetch/package.json +7 -7
  50. package/dist/node_modules/minipass-sized/dist/commonjs/index.js +69 -0
  51. package/dist/node_modules/minipass-sized/dist/esm/index.js +64 -0
  52. package/dist/node_modules/minipass-sized/package.json +39 -9
  53. package/dist/node_modules/node-gyp/.release-please-manifest.json +1 -1
  54. package/dist/node_modules/node-gyp/bin/node-gyp.js +7 -0
  55. package/dist/node_modules/node-gyp/gyp/.release-please-manifest.json +1 -1
  56. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +3 -3
  57. package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +26 -1
  58. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +1 -1
  59. package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +3 -4
  60. package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +1 -1
  61. package/dist/node_modules/node-gyp/gyp/pyproject.toml +1 -1
  62. package/dist/node_modules/node-gyp/lib/build.js +2 -2
  63. package/dist/node_modules/node-gyp/lib/find-python.js +2 -8
  64. package/dist/node_modules/node-gyp/lib/find-visualstudio.js +11 -5
  65. package/dist/node_modules/node-gyp/lib/install.js +1 -1
  66. package/dist/node_modules/node-gyp/lib/process-release.js +3 -3
  67. package/dist/node_modules/node-gyp/package.json +13 -13
  68. package/dist/node_modules/nopt/package.json +5 -5
  69. package/dist/node_modules/path-scurry/package.json +8 -24
  70. package/dist/node_modules/proc-log/lib/index.js +10 -5
  71. package/dist/node_modules/proc-log/package.json +5 -5
  72. package/dist/node_modules/retry/lib/retry.js +2 -2
  73. package/dist/node_modules/retry/lib/retry_operation.js +10 -6
  74. package/dist/node_modules/retry/package.json +6 -2
  75. package/dist/node_modules/ssri/lib/index.js +33 -63
  76. package/dist/node_modules/ssri/package.json +17 -17
  77. package/dist/node_modules/tar/dist/commonjs/index.min.js +2 -2
  78. package/dist/node_modules/tar/dist/commonjs/unpack.js +4 -4
  79. package/dist/node_modules/tar/dist/esm/index.min.js +2 -2
  80. package/dist/node_modules/tar/dist/esm/unpack.js +4 -4
  81. package/dist/node_modules/tar/package.json +6 -6
  82. package/dist/node_modules/unique-filename/package.json +5 -5
  83. package/dist/node_modules/unique-slug/package.json +4 -4
  84. package/dist/node_modules/which/package.json +29 -20
  85. package/dist/pnpm.mjs +225713 -208017
  86. package/dist/worker.js +4838 -5926
  87. package/package.json +10 -10
  88. package/setup.js +12 -14
  89. package/dist/node_modules/@isaacs/cliui/dist/commonjs/ansi-regex/index.js +0 -16
  90. package/dist/node_modules/@isaacs/cliui/dist/commonjs/ansi-styles/index.js +0 -170
  91. package/dist/node_modules/@isaacs/cliui/dist/commonjs/eastasianwidth/index.js +0 -307
  92. package/dist/node_modules/@isaacs/cliui/dist/commonjs/emoji-regex/index.js +0 -7
  93. package/dist/node_modules/@isaacs/cliui/dist/commonjs/index.js +0 -322
  94. package/dist/node_modules/@isaacs/cliui/dist/commonjs/index.min.js +0 -12
  95. package/dist/node_modules/@isaacs/cliui/dist/commonjs/string-width/index.js +0 -49
  96. package/dist/node_modules/@isaacs/cliui/dist/commonjs/strip-ansi/index.js +0 -8
  97. package/dist/node_modules/@isaacs/cliui/dist/commonjs/wrap-ansi/index.js +0 -176
  98. package/dist/node_modules/@isaacs/cliui/dist/esm/ansi-regex/index.js +0 -12
  99. package/dist/node_modules/@isaacs/cliui/dist/esm/ansi-styles/index.js +0 -167
  100. package/dist/node_modules/@isaacs/cliui/dist/esm/eastasianwidth/index.js +0 -299
  101. package/dist/node_modules/@isaacs/cliui/dist/esm/emoji-regex/index.js +0 -3
  102. package/dist/node_modules/@isaacs/cliui/dist/esm/index.js +0 -317
  103. package/dist/node_modules/@isaacs/cliui/dist/esm/index.min.js +0 -12
  104. package/dist/node_modules/@isaacs/cliui/dist/esm/string-width/index.js +0 -46
  105. package/dist/node_modules/@isaacs/cliui/dist/esm/strip-ansi/index.js +0 -4
  106. package/dist/node_modules/@isaacs/cliui/dist/esm/wrap-ansi/index.js +0 -172
  107. package/dist/node_modules/@isaacs/cliui/package.json +0 -163
  108. package/dist/node_modules/cross-spawn/LICENSE +0 -21
  109. package/dist/node_modules/cross-spawn/index.js +0 -39
  110. package/dist/node_modules/cross-spawn/lib/enoent.js +0 -59
  111. package/dist/node_modules/cross-spawn/lib/parse.js +0 -91
  112. package/dist/node_modules/cross-spawn/lib/util/escape.js +0 -47
  113. package/dist/node_modules/cross-spawn/lib/util/readShebang.js +0 -23
  114. package/dist/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -52
  115. package/dist/node_modules/cross-spawn/package.json +0 -73
  116. package/dist/node_modules/encoding/.prettierrc.js +0 -8
  117. package/dist/node_modules/encoding/LICENSE +0 -16
  118. package/dist/node_modules/encoding/lib/encoding.js +0 -83
  119. package/dist/node_modules/encoding/package.json +0 -18
  120. package/dist/node_modules/err-code/.eslintrc.json +0 -7
  121. package/dist/node_modules/err-code/bower.json +0 -30
  122. package/dist/node_modules/err-code/index.js +0 -47
  123. package/dist/node_modules/err-code/index.umd.js +0 -51
  124. package/dist/node_modules/err-code/package.json +0 -34
  125. package/dist/node_modules/foreground-child/LICENSE +0 -15
  126. package/dist/node_modules/foreground-child/dist/commonjs/all-signals.js +0 -58
  127. package/dist/node_modules/foreground-child/dist/commonjs/index.js +0 -123
  128. package/dist/node_modules/foreground-child/dist/commonjs/proxy-signals.js +0 -38
  129. package/dist/node_modules/foreground-child/dist/commonjs/watchdog.js +0 -50
  130. package/dist/node_modules/foreground-child/dist/esm/all-signals.js +0 -52
  131. package/dist/node_modules/foreground-child/dist/esm/index.js +0 -115
  132. package/dist/node_modules/foreground-child/dist/esm/proxy-signals.js +0 -34
  133. package/dist/node_modules/foreground-child/dist/esm/watchdog.js +0 -46
  134. package/dist/node_modules/foreground-child/package.json +0 -106
  135. package/dist/node_modules/glob/dist/esm/bin.d.mts +0 -3
  136. package/dist/node_modules/glob/dist/esm/bin.mjs +0 -346
  137. package/dist/node_modules/iconv-lite/.github/dependabot.yml +0 -11
  138. package/dist/node_modules/iconv-lite/.idea/codeStyles/Project.xml +0 -47
  139. package/dist/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +0 -5
  140. package/dist/node_modules/iconv-lite/.idea/iconv-lite.iml +0 -12
  141. package/dist/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +0 -6
  142. package/dist/node_modules/iconv-lite/.idea/modules.xml +0 -8
  143. package/dist/node_modules/iconv-lite/.idea/vcs.xml +0 -6
  144. package/dist/node_modules/isexe/LICENSE +0 -15
  145. package/dist/node_modules/isexe/index.js +0 -57
  146. package/dist/node_modules/isexe/mode.js +0 -41
  147. package/dist/node_modules/isexe/windows.js +0 -42
  148. package/dist/node_modules/jackspeak/dist/commonjs/index.js +0 -944
  149. package/dist/node_modules/jackspeak/dist/commonjs/index.min.js +0 -33
  150. package/dist/node_modules/jackspeak/dist/commonjs/package.json +0 -3
  151. package/dist/node_modules/jackspeak/dist/esm/index.js +0 -936
  152. package/dist/node_modules/jackspeak/dist/esm/index.min.js +0 -33
  153. package/dist/node_modules/jackspeak/dist/esm/package.json +0 -3
  154. package/dist/node_modules/jackspeak/package.json +0 -115
  155. package/dist/node_modules/lru-cache/LICENSE +0 -15
  156. package/dist/node_modules/minipass/LICENSE +0 -15
  157. package/dist/node_modules/minipass-sized/index.js +0 -67
  158. package/dist/node_modules/minipass-sized/node_modules/minipass/LICENSE +0 -15
  159. package/dist/node_modules/minipass-sized/node_modules/minipass/index.js +0 -649
  160. package/dist/node_modules/minipass-sized/node_modules/minipass/package.json +0 -56
  161. package/dist/node_modules/minipass-sized/package-lock.json +0 -3464
  162. package/dist/node_modules/node-gyp/node_modules/isexe/dist/commonjs/package.json +0 -3
  163. package/dist/node_modules/node-gyp/node_modules/isexe/dist/esm/package.json +0 -3
  164. package/dist/node_modules/node-gyp/node_modules/isexe/package.json +0 -78
  165. package/dist/node_modules/node-gyp/node_modules/which/LICENSE +0 -15
  166. package/dist/node_modules/node-gyp/node_modules/which/package.json +0 -52
  167. package/dist/node_modules/package-json-from-dist/dist/commonjs/index.js +0 -134
  168. package/dist/node_modules/package-json-from-dist/dist/commonjs/package.json +0 -3
  169. package/dist/node_modules/package-json-from-dist/dist/esm/index.js +0 -129
  170. package/dist/node_modules/package-json-from-dist/dist/esm/package.json +0 -3
  171. package/dist/node_modules/package-json-from-dist/package.json +0 -68
  172. package/dist/node_modules/path-key/index.js +0 -16
  173. package/dist/node_modules/path-key/license +0 -9
  174. package/dist/node_modules/path-key/package.json +0 -39
  175. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +0 -1589
  176. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +0 -2
  177. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +0 -3
  178. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +0 -1585
  179. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +0 -2
  180. package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +0 -3
  181. package/dist/node_modules/path-scurry/node_modules/lru-cache/package.json +0 -101
  182. package/dist/node_modules/promise-retry/index.js +0 -52
  183. package/dist/node_modules/promise-retry/package.json +0 -37
  184. package/dist/node_modules/retry/equation.gif +0 -0
  185. package/dist/node_modules/shebang-command/index.js +0 -19
  186. package/dist/node_modules/shebang-command/license +0 -9
  187. package/dist/node_modules/shebang-command/package.json +0 -34
  188. package/dist/node_modules/shebang-regex/index.js +0 -2
  189. package/dist/node_modules/shebang-regex/license +0 -9
  190. package/dist/node_modules/shebang-regex/package.json +0 -35
  191. package/dist/node_modules/signal-exit/LICENSE.txt +0 -16
  192. package/dist/node_modules/signal-exit/dist/cjs/browser.js +0 -10
  193. package/dist/node_modules/signal-exit/dist/cjs/index.js +0 -279
  194. package/dist/node_modules/signal-exit/dist/cjs/package.json +0 -3
  195. package/dist/node_modules/signal-exit/dist/cjs/signals.js +0 -42
  196. package/dist/node_modules/signal-exit/dist/mjs/browser.js +0 -4
  197. package/dist/node_modules/signal-exit/dist/mjs/index.js +0 -275
  198. package/dist/node_modules/signal-exit/dist/mjs/package.json +0 -3
  199. package/dist/node_modules/signal-exit/dist/mjs/signals.js +0 -39
  200. package/dist/node_modules/signal-exit/package.json +0 -106
  201. package/dist/node_modules/which/bin/node-which +0 -52
  202. package/dist/node_modules/which/which.js +0 -125
  203. /package/dist/node_modules/{promise-retry → @gar/promise-retry}/LICENSE +0 -0
  204. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/index.js +0 -0
  205. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/index.min.js +0 -0
  206. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/options.js +0 -0
  207. /package/dist/node_modules/{@isaacs/cliui → isexe}/dist/commonjs/package.json +0 -0
  208. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/posix.js +0 -0
  209. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/win32.js +0 -0
  210. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/index.js +0 -0
  211. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/index.min.js +0 -0
  212. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/options.js +0 -0
  213. /package/dist/node_modules/{@isaacs/cliui → isexe}/dist/esm/package.json +0 -0
  214. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/posix.js +0 -0
  215. /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/win32.js +0 -0
  216. /package/dist/node_modules/{foreground-child → minipass-sized}/dist/commonjs/package.json +0 -0
  217. /package/dist/node_modules/{foreground-child → minipass-sized}/dist/esm/package.json +0 -0
  218. /package/dist/node_modules/{node-gyp/node_modules/which → which}/bin/which.js +0 -0
  219. /package/dist/node_modules/{node-gyp/node_modules/which → which}/lib/index.js +0 -0
@@ -1,31 +1,78 @@
1
1
  {
2
2
  "name": "isexe",
3
- "version": "2.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "Minimal module to check if a file is executable.",
5
- "main": "index.js",
6
- "directories": {
7
- "test": "test"
5
+ "main": "./dist/commonjs/index.min.js",
6
+ "module": "./dist/esm/index.min.js",
7
+ "types": "./dist/commonjs/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "tshy": {
12
+ "selfLink": false,
13
+ "exports": {
14
+ "./raw": "./src/index.ts",
15
+ "./package.json": "./package.json",
16
+ ".": {
17
+ "import": {
18
+ "types": "./dist/esm/index.d.ts",
19
+ "default": "./dist/esm/index.min.js"
20
+ },
21
+ "require": {
22
+ "types": "./dist/commonjs/index.d.ts",
23
+ "default": "./dist/commonjs/index.min.js"
24
+ }
25
+ }
26
+ }
27
+ },
28
+ "exports": {
29
+ "./raw": {
30
+ "import": {
31
+ "types": "./dist/esm/index.d.ts",
32
+ "default": "./dist/esm/index.js"
33
+ },
34
+ "require": {
35
+ "types": "./dist/commonjs/index.d.ts",
36
+ "default": "./dist/commonjs/index.js"
37
+ }
38
+ },
39
+ "./package.json": "./package.json",
40
+ ".": {
41
+ "import": {
42
+ "types": "./dist/esm/index.d.ts",
43
+ "default": "./dist/esm/index.min.js"
44
+ },
45
+ "require": {
46
+ "types": "./dist/commonjs/index.d.ts",
47
+ "default": "./dist/commonjs/index.min.js"
48
+ }
49
+ }
8
50
  },
9
51
  "devDependencies": {
10
- "mkdirp": "^0.5.1",
11
- "rimraf": "^2.5.0",
12
- "tap": "^10.3.0"
52
+ "@types/node": "^25.2.1",
53
+ "esbuild": "^0.27.3",
54
+ "prettier": "^3.8.1",
55
+ "tap": "^21.5.1",
56
+ "tshy": "^3.1.3",
57
+ "typedoc": "^0.28.16"
13
58
  },
14
59
  "scripts": {
15
- "test": "tap test/*.js --100",
16
60
  "preversion": "npm test",
17
61
  "postversion": "npm publish",
18
- "postpublish": "git push origin --all; git push origin --tags"
62
+ "prepublishOnly": "git push origin --follow-tags",
63
+ "prepare": "tshy && bash build.sh",
64
+ "pretest": "npm run prepare",
65
+ "presnap": "npm run prepare",
66
+ "test": "tap",
67
+ "snap": "tap",
68
+ "format": "prettier --write .",
69
+ "typedoc": "typedoc"
19
70
  },
20
71
  "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
21
- "license": "ISC",
22
- "repository": {
23
- "type": "git",
24
- "url": "git+https://github.com/isaacs/isexe.git"
25
- },
26
- "keywords": [],
27
- "bugs": {
28
- "url": "https://github.com/isaacs/isexe/issues"
72
+ "license": "BlueOak-1.0.0",
73
+ "repository": "https://github.com/isaacs/isexe",
74
+ "engines": {
75
+ "node": ">=20"
29
76
  },
30
- "homepage": "https://github.com/isaacs/isexe#readme"
77
+ "type": "module"
31
78
  }
@@ -4,18 +4,20 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LRUCache = void 0;
7
- const perf = typeof performance === 'object' &&
7
+ const defaultPerf = (typeof performance === 'object' &&
8
8
  performance &&
9
- typeof performance.now === 'function'
10
- ? performance
9
+ typeof performance.now === 'function') ?
10
+ performance
11
11
  : Date;
12
12
  const warned = new Set();
13
13
  /* c8 ignore start */
14
- const PROCESS = (typeof process === 'object' && !!process ? process : {});
14
+ const PROCESS = (typeof process === 'object' && !!process ?
15
+ process
16
+ : {});
15
17
  /* c8 ignore start */
16
18
  const emitWarning = (msg, type, code, fn) => {
17
- typeof PROCESS.emitWarning === 'function'
18
- ? PROCESS.emitWarning(msg, type, code, fn)
19
+ typeof PROCESS.emitWarning === 'function' ?
20
+ PROCESS.emitWarning(msg, type, code, fn)
19
21
  : console.error(`[${code}] ${type}: ${msg}`);
20
22
  };
21
23
  let AC = globalThis.AbortController;
@@ -79,16 +81,11 @@ const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
79
81
  // zeroes at init time is brutal when you get that big.
80
82
  // But why not be complete?
81
83
  // Maybe in the future, these limits will have expanded.
82
- const getUintArray = (max) => !isPosInt(max)
83
- ? null
84
- : max <= Math.pow(2, 8)
85
- ? Uint8Array
86
- : max <= Math.pow(2, 16)
87
- ? Uint16Array
88
- : max <= Math.pow(2, 32)
89
- ? Uint32Array
90
- : max <= Number.MAX_SAFE_INTEGER
91
- ? ZeroArray
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
92
89
  : null;
93
90
  /* c8 ignore stop */
94
91
  class ZeroArray extends Array {
@@ -147,9 +144,17 @@ class LRUCache {
147
144
  #max;
148
145
  #maxSize;
149
146
  #dispose;
147
+ #onInsert;
150
148
  #disposeAfter;
151
149
  #fetchMethod;
152
150
  #memoMethod;
151
+ #perf;
152
+ /**
153
+ * {@link LRUCache.OptionsBase.perf}
154
+ */
155
+ get perf() {
156
+ return this.#perf;
157
+ }
153
158
  /**
154
159
  * {@link LRUCache.OptionsBase.ttl}
155
160
  */
@@ -225,9 +230,11 @@ class LRUCache {
225
230
  #sizes;
226
231
  #starts;
227
232
  #ttls;
233
+ #autopurgeTimers;
228
234
  #hasDispose;
229
235
  #hasFetchMethod;
230
236
  #hasDisposeAfter;
237
+ #hasOnInsert;
231
238
  /**
232
239
  * Do not call this method unless you need to inspect the
233
240
  * inner workings of the cache. If anything returned by this
@@ -242,6 +249,7 @@ class LRUCache {
242
249
  // properties
243
250
  starts: c.#starts,
244
251
  ttls: c.#ttls,
252
+ autopurgeTimers: c.#autopurgeTimers,
245
253
  sizes: c.#sizes,
246
254
  keyMap: c.#keyMap,
247
255
  keyList: c.#keyList,
@@ -304,6 +312,12 @@ class LRUCache {
304
312
  get dispose() {
305
313
  return this.#dispose;
306
314
  }
315
+ /**
316
+ * {@link LRUCache.OptionsBase.onInsert} (read-only)
317
+ */
318
+ get onInsert() {
319
+ return this.#onInsert;
320
+ }
307
321
  /**
308
322
  * {@link LRUCache.OptionsBase.disposeAfter} (read-only)
309
323
  */
@@ -311,7 +325,13 @@ class LRUCache {
311
325
  return this.#disposeAfter;
312
326
  }
313
327
  constructor(options) {
314
- const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, } = 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;
315
335
  if (max !== 0 && !isPosInt(max)) {
316
336
  throw new TypeError('max option must be a nonnegative integer');
317
337
  }
@@ -331,13 +351,11 @@ class LRUCache {
331
351
  throw new TypeError('sizeCalculation set to non-function');
332
352
  }
333
353
  }
334
- if (memoMethod !== undefined &&
335
- typeof memoMethod !== 'function') {
354
+ if (memoMethod !== undefined && typeof memoMethod !== 'function') {
336
355
  throw new TypeError('memoMethod must be a function if defined');
337
356
  }
338
357
  this.#memoMethod = memoMethod;
339
- if (fetchMethod !== undefined &&
340
- typeof fetchMethod !== 'function') {
358
+ if (fetchMethod !== undefined && typeof fetchMethod !== 'function') {
341
359
  throw new TypeError('fetchMethod must be a function if specified');
342
360
  }
343
361
  this.#fetchMethod = fetchMethod;
@@ -355,6 +373,9 @@ class LRUCache {
355
373
  if (typeof dispose === 'function') {
356
374
  this.#dispose = dispose;
357
375
  }
376
+ if (typeof onInsert === 'function') {
377
+ this.#onInsert = onInsert;
378
+ }
358
379
  if (typeof disposeAfter === 'function') {
359
380
  this.#disposeAfter = disposeAfter;
360
381
  this.#disposed = [];
@@ -364,6 +385,7 @@ class LRUCache {
364
385
  this.#disposed = undefined;
365
386
  }
366
387
  this.#hasDispose = !!this.#dispose;
388
+ this.#hasOnInsert = !!this.#onInsert;
367
389
  this.#hasDisposeAfter = !!this.#disposeAfter;
368
390
  this.noDisposeOnSet = !!noDisposeOnSet;
369
391
  this.noUpdateTTL = !!noUpdateTTL;
@@ -388,9 +410,7 @@ class LRUCache {
388
410
  this.updateAgeOnGet = !!updateAgeOnGet;
389
411
  this.updateAgeOnHas = !!updateAgeOnHas;
390
412
  this.ttlResolution =
391
- isPosInt(ttlResolution) || ttlResolution === 0
392
- ? ttlResolution
393
- : 1;
413
+ isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1;
394
414
  this.ttlAutopurge = !!ttlAutopurge;
395
415
  this.ttl = ttl || 0;
396
416
  if (this.ttl) {
@@ -425,26 +445,45 @@ class LRUCache {
425
445
  const starts = new ZeroArray(this.#max);
426
446
  this.#ttls = ttls;
427
447
  this.#starts = starts;
428
- this.#setItemTTL = (index, ttl, start = perf.now()) => {
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()) => {
429
453
  starts[index] = ttl !== 0 ? start : 0;
430
454
  ttls[index] = ttl;
431
- if (ttl !== 0 && this.ttlAutopurge) {
432
- const t = setTimeout(() => {
433
- if (this.#isStale(index)) {
434
- this.#delete(this.#keyList[index], 'expire');
435
- }
436
- }, ttl + 1);
437
- // unref() not supported on all platforms
438
- /* c8 ignore start */
439
- if (t.unref) {
440
- t.unref();
441
- }
442
- /* c8 ignore stop */
443
- }
455
+ setPurgetTimer(index, ttl);
444
456
  };
445
457
  this.#updateItemAge = index => {
446
- starts[index] = ttls[index] !== 0 ? perf.now() : 0;
458
+ starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
459
+ setPurgetTimer(index, ttls[index]);
447
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
+ };
448
487
  this.#statusTTL = (status, index) => {
449
488
  if (ttls[index]) {
450
489
  const ttl = ttls[index];
@@ -463,7 +502,7 @@ class LRUCache {
463
502
  // that costly call repeatedly.
464
503
  let cachedNow = 0;
465
504
  const getNow = () => {
466
- const n = perf.now();
505
+ const n = this.#perf.now();
467
506
  if (this.ttlResolution > 0) {
468
507
  cachedNow = n;
469
508
  const t = setTimeout(() => (cachedNow = 0), this.ttlResolution);
@@ -631,8 +670,7 @@ class LRUCache {
631
670
  *keys() {
632
671
  for (const i of this.#indexes()) {
633
672
  const k = this.#keyList[i];
634
- if (k !== undefined &&
635
- !this.#isBackgroundFetch(this.#valList[i])) {
673
+ if (k !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
636
674
  yield k;
637
675
  }
638
676
  }
@@ -646,8 +684,7 @@ class LRUCache {
646
684
  *rkeys() {
647
685
  for (const i of this.#rindexes()) {
648
686
  const k = this.#keyList[i];
649
- if (k !== undefined &&
650
- !this.#isBackgroundFetch(this.#valList[i])) {
687
+ if (k !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
651
688
  yield k;
652
689
  }
653
690
  }
@@ -659,8 +696,7 @@ class LRUCache {
659
696
  *values() {
660
697
  for (const i of this.#indexes()) {
661
698
  const v = this.#valList[i];
662
- if (v !== undefined &&
663
- !this.#isBackgroundFetch(this.#valList[i])) {
699
+ if (v !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
664
700
  yield this.#valList[i];
665
701
  }
666
702
  }
@@ -674,8 +710,7 @@ class LRUCache {
674
710
  *rvalues() {
675
711
  for (const i of this.#rindexes()) {
676
712
  const v = this.#valList[i];
677
- if (v !== undefined &&
678
- !this.#isBackgroundFetch(this.#valList[i])) {
713
+ if (v !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
679
714
  yield this.#valList[i];
680
715
  }
681
716
  }
@@ -700,9 +735,7 @@ class LRUCache {
700
735
  find(fn, getOptions = {}) {
701
736
  for (const i of this.#indexes()) {
702
737
  const v = this.#valList[i];
703
- const value = this.#isBackgroundFetch(v)
704
- ? v.__staleWhileFetching
705
- : v;
738
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
706
739
  if (value === undefined)
707
740
  continue;
708
741
  if (fn(value, this.#keyList[i], this)) {
@@ -724,9 +757,7 @@ class LRUCache {
724
757
  forEach(fn, thisp = this) {
725
758
  for (const i of this.#indexes()) {
726
759
  const v = this.#valList[i];
727
- const value = this.#isBackgroundFetch(v)
728
- ? v.__staleWhileFetching
729
- : v;
760
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
730
761
  if (value === undefined)
731
762
  continue;
732
763
  fn.call(thisp, value, this.#keyList[i], this);
@@ -739,9 +770,7 @@ class LRUCache {
739
770
  rforEach(fn, thisp = this) {
740
771
  for (const i of this.#rindexes()) {
741
772
  const v = this.#valList[i];
742
- const value = this.#isBackgroundFetch(v)
743
- ? v.__staleWhileFetching
744
- : v;
773
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
745
774
  if (value === undefined)
746
775
  continue;
747
776
  fn.call(thisp, value, this.#keyList[i], this);
@@ -778,17 +807,18 @@ class LRUCache {
778
807
  if (i === undefined)
779
808
  return undefined;
780
809
  const v = this.#valList[i];
781
- const value = this.#isBackgroundFetch(v)
782
- ? v.__staleWhileFetching
783
- : v;
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;
784
813
  if (value === undefined)
785
814
  return undefined;
815
+ /* c8 ignore end */
786
816
  const entry = { value };
787
817
  if (this.#ttls && this.#starts) {
788
818
  const ttl = this.#ttls[i];
789
819
  const start = this.#starts[i];
790
820
  if (ttl && start) {
791
- const remain = ttl - (perf.now() - start);
821
+ const remain = ttl - (this.#perf.now() - start);
792
822
  entry.ttl = remain;
793
823
  entry.start = Date.now();
794
824
  }
@@ -800,7 +830,7 @@ class LRUCache {
800
830
  }
801
831
  /**
802
832
  * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
803
- * passed to {@link LRLUCache#load}.
833
+ * passed to {@link LRUCache#load}.
804
834
  *
805
835
  * The `start` fields are calculated relative to a portable `Date.now()`
806
836
  * timestamp, even if `performance.now()` is available.
@@ -816,9 +846,7 @@ class LRUCache {
816
846
  for (const i of this.#indexes({ allowStale: true })) {
817
847
  const key = this.#keyList[i];
818
848
  const v = this.#valList[i];
819
- const value = this.#isBackgroundFetch(v)
820
- ? v.__staleWhileFetching
821
- : v;
849
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
822
850
  if (value === undefined || key === undefined)
823
851
  continue;
824
852
  const entry = { value };
@@ -826,7 +854,7 @@ class LRUCache {
826
854
  entry.ttl = this.#ttls[i];
827
855
  // always dump the start relative to a portable timestamp
828
856
  // it's ok for this to be a bit slow, it's a rare operation.
829
- const age = perf.now() - this.#starts[i];
857
+ const age = this.#perf.now() - this.#starts[i];
830
858
  entry.start = Math.floor(Date.now() - age);
831
859
  }
832
860
  if (this.#sizes) {
@@ -856,7 +884,7 @@ class LRUCache {
856
884
  //
857
885
  // it's ok for this to be a bit slow, it's a rare operation.
858
886
  const age = Date.now() - entry.start;
859
- entry.start = perf.now() - age;
887
+ entry.start = this.#perf.now() - age;
860
888
  }
861
889
  this.set(key, entry.value, entry);
862
890
  }
@@ -913,12 +941,9 @@ class LRUCache {
913
941
  let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
914
942
  if (index === undefined) {
915
943
  // addition
916
- index = (this.#size === 0
917
- ? this.#tail
918
- : this.#free.length !== 0
919
- ? this.#free.pop()
920
- : this.#size === this.#max
921
- ? this.#evict(false)
944
+ index = (this.#size === 0 ? this.#tail
945
+ : this.#free.length !== 0 ? this.#free.pop()
946
+ : this.#size === this.#max ? this.#evict(false)
922
947
  : this.#size);
923
948
  this.#keyList[index] = k;
924
949
  this.#valList[index] = v;
@@ -931,6 +956,9 @@ class LRUCache {
931
956
  if (status)
932
957
  status.set = 'add';
933
958
  noUpdateTTL = false;
959
+ if (this.#hasOnInsert) {
960
+ this.#onInsert?.(v, k, 'add');
961
+ }
934
962
  }
935
963
  else {
936
964
  // update
@@ -962,8 +990,8 @@ class LRUCache {
962
990
  this.#valList[index] = v;
963
991
  if (status) {
964
992
  status.set = 'replace';
965
- const oldValue = oldVal && this.#isBackgroundFetch(oldVal)
966
- ? oldVal.__staleWhileFetching
993
+ const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ?
994
+ oldVal.__staleWhileFetching
967
995
  : oldVal;
968
996
  if (oldValue !== undefined)
969
997
  status.oldValue = oldValue;
@@ -972,6 +1000,9 @@ class LRUCache {
972
1000
  else if (status) {
973
1001
  status.set = 'update';
974
1002
  }
1003
+ if (this.#hasOnInsert) {
1004
+ this.onInsert?.(v, k, v === oldVal ? 'update' : 'replace');
1005
+ }
975
1006
  }
976
1007
  if (ttl !== 0 && !this.#ttls) {
977
1008
  this.#initializeTTLTracking();
@@ -1037,6 +1068,10 @@ class LRUCache {
1037
1068
  }
1038
1069
  }
1039
1070
  this.#removeItemSize(head);
1071
+ if (this.#autopurgeTimers?.[head]) {
1072
+ clearTimeout(this.#autopurgeTimers[head]);
1073
+ this.#autopurgeTimers[head] = undefined;
1074
+ }
1040
1075
  // if we aren't about to use the index, then null these out
1041
1076
  if (free) {
1042
1077
  this.#keyList[head] = undefined;
@@ -1109,8 +1144,7 @@ class LRUCache {
1109
1144
  peek(k, peekOptions = {}) {
1110
1145
  const { allowStale = this.allowStale } = peekOptions;
1111
1146
  const index = this.#keyMap.get(k);
1112
- if (index === undefined ||
1113
- (!allowStale && this.#isStale(index))) {
1147
+ if (index === undefined || (!allowStale && this.#isStale(index))) {
1114
1148
  return;
1115
1149
  }
1116
1150
  const v = this.#valList[index];
@@ -1136,6 +1170,8 @@ class LRUCache {
1136
1170
  const cb = (v, updateCache = false) => {
1137
1171
  const { aborted } = ac.signal;
1138
1172
  const ignoreAbort = options.ignoreFetchAbort && v !== undefined;
1173
+ const proceed = options.ignoreFetchAbort ||
1174
+ !!(options.allowStaleOnFetchAbort && v !== undefined);
1139
1175
  if (options.status) {
1140
1176
  if (aborted && !updateCache) {
1141
1177
  options.status.fetchAborted = true;
@@ -1148,13 +1184,17 @@ class LRUCache {
1148
1184
  }
1149
1185
  }
1150
1186
  if (aborted && !ignoreAbort && !updateCache) {
1151
- return fetchFail(ac.signal.reason);
1187
+ return fetchFail(ac.signal.reason, proceed);
1152
1188
  }
1153
1189
  // either we didn't abort, and are still here, or we did, and ignored
1154
1190
  const bf = p;
1155
- if (this.#valList[index] === 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)) {
1156
1196
  if (v === undefined) {
1157
- if (bf.__staleWhileFetching) {
1197
+ if (bf.__staleWhileFetching !== undefined) {
1158
1198
  this.#valList[index] = bf.__staleWhileFetching;
1159
1199
  }
1160
1200
  else {
@@ -1174,9 +1214,10 @@ class LRUCache {
1174
1214
  options.status.fetchRejected = true;
1175
1215
  options.status.fetchError = er;
1176
1216
  }
1177
- return fetchFail(er);
1217
+ // do not pass go, do not collect $200
1218
+ return fetchFail(er, false);
1178
1219
  };
1179
- const fetchFail = (er) => {
1220
+ const fetchFail = (er, proceed) => {
1180
1221
  const { aborted } = ac.signal;
1181
1222
  const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
1182
1223
  const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
@@ -1185,7 +1226,7 @@ class LRUCache {
1185
1226
  if (this.#valList[index] === p) {
1186
1227
  // if we allow stale on fetch rejections, then we need to ensure that
1187
1228
  // the stale value is not removed from the cache when the fetch fails.
1188
- const del = !noDelete || bf.__staleWhileFetching === undefined;
1229
+ const del = !noDelete || (!proceed && bf.__staleWhileFetching === undefined);
1189
1230
  if (del) {
1190
1231
  this.#delete(k, 'fetch');
1191
1232
  }
@@ -1216,8 +1257,7 @@ class LRUCache {
1216
1257
  // defer check until we are actually aborting,
1217
1258
  // so fetchMethod can override.
1218
1259
  ac.signal.addEventListener('abort', () => {
1219
- if (!options.ignoreFetchAbort ||
1220
- options.allowStaleOnFetchAbort) {
1260
+ if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
1221
1261
  res(undefined);
1222
1262
  // when it eventually resolves, update the cache.
1223
1263
  if (options.allowStaleOnFetchAbort) {
@@ -1449,6 +1489,10 @@ class LRUCache {
1449
1489
  if (this.#size !== 0) {
1450
1490
  const index = this.#keyMap.get(k);
1451
1491
  if (index !== undefined) {
1492
+ if (this.#autopurgeTimers?.[index]) {
1493
+ clearTimeout(this.#autopurgeTimers?.[index]);
1494
+ this.#autopurgeTimers[index] = undefined;
1495
+ }
1452
1496
  deleted = true;
1453
1497
  if (this.#size === 1) {
1454
1498
  this.#clear(reason);
@@ -1524,6 +1568,11 @@ class LRUCache {
1524
1568
  if (this.#ttls && this.#starts) {
1525
1569
  this.#ttls.fill(0);
1526
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);
1527
1576
  }
1528
1577
  if (this.#sizes) {
1529
1578
  this.#sizes.fill(0);