@socketsecurity/cli-with-sentry 1.0.69 → 1.0.70

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.
@@ -24,14 +24,14 @@ const get = { exports: {} }
24
24
 
25
25
  const minipassCollect = { exports: {} }
26
26
 
27
- const commonjs$4 = {}
27
+ const commonjs$7 = {}
28
28
 
29
- let hasRequiredCommonjs$4
30
- function requireCommonjs$4() {
31
- if (hasRequiredCommonjs$4) {
32
- return commonjs$4
29
+ let hasRequiredCommonjs$7
30
+ function requireCommonjs$7() {
31
+ if (hasRequiredCommonjs$7) {
32
+ return commonjs$7
33
33
  }
34
- hasRequiredCommonjs$4 = 1
34
+ hasRequiredCommonjs$7 = 1
35
35
  ;(function (exports) {
36
36
  const __importDefault =
37
37
  (this && this.__importDefault) ||
@@ -1160,8 +1160,8 @@ function requireCommonjs$4() {
1160
1160
  }
1161
1161
  }
1162
1162
  exports.Minipass = Minipass
1163
- })(commonjs$4)
1164
- return commonjs$4
1163
+ })(commonjs$7)
1164
+ return commonjs$7
1165
1165
  }
1166
1166
 
1167
1167
  let hasRequiredMinipassCollect
@@ -1170,7 +1170,7 @@ function requireMinipassCollect() {
1170
1170
  return minipassCollect.exports
1171
1171
  }
1172
1172
  hasRequiredMinipassCollect = 1
1173
- const { Minipass } = requireCommonjs$4()
1173
+ const { Minipass } = requireCommonjs$7()
1174
1174
  const _data = Symbol('_data')
1175
1175
  const _length = Symbol('_length')
1176
1176
  class Collect extends Minipass {
@@ -2103,7 +2103,7 @@ function requireLib$5() {
2103
2103
  }
2104
2104
  hasRequiredLib$5 = 1
2105
2105
  const crypto = require$$0$2
2106
- const { Minipass } = requireCommonjs$4()
2106
+ const { Minipass } = requireCommonjs$7()
2107
2107
  const SPEC_ALGORITHMS = ['sha512', 'sha384', 'sha256']
2108
2108
  const DEFAULT_ALGORITHMS = ['sha512']
2109
2109
 
@@ -6341,7 +6341,7 @@ function requireEntryIndex() {
6341
6341
  hasRequiredEntryIndex = 1
6342
6342
  const crypto = require$$0$2
6343
6343
  const { appendFile, mkdir, readFile, readdir, rm, writeFile } = require$$0$5
6344
- const { Minipass } = requireCommonjs$4()
6344
+ const { Minipass } = requireCommonjs$7()
6345
6345
  const path = require$$0$3
6346
6346
  const ssri = requireLib$5()
6347
6347
  const uniqueFilename = requireLib$3()
@@ -6670,21 +6670,21 @@ function requireEntryIndex() {
6670
6670
 
6671
6671
  const memoization = { exports: {} }
6672
6672
 
6673
- const commonjs$3 = {}
6673
+ const commonjs$6 = {}
6674
6674
 
6675
- let hasRequiredCommonjs$3
6676
- function requireCommonjs$3() {
6677
- if (hasRequiredCommonjs$3) {
6678
- return commonjs$3
6675
+ let hasRequiredCommonjs$6
6676
+ function requireCommonjs$6() {
6677
+ if (hasRequiredCommonjs$6) {
6678
+ return commonjs$6
6679
6679
  }
6680
- hasRequiredCommonjs$3 = 1
6680
+ hasRequiredCommonjs$6 = 1
6681
6681
  /**
6682
6682
  * @module LRUCache
6683
6683
  */
6684
- Object.defineProperty(commonjs$3, '__esModule', {
6684
+ Object.defineProperty(commonjs$6, '__esModule', {
6685
6685
  value: true
6686
6686
  })
6687
- commonjs$3.LRUCache = void 0
6687
+ commonjs$6.LRUCache = void 0
6688
6688
  const perf =
6689
6689
  typeof performance === 'object' &&
6690
6690
  performance &&
@@ -6838,6 +6838,7 @@ function requireCommonjs$3() {
6838
6838
  #max
6839
6839
  #maxSize
6840
6840
  #dispose
6841
+ #onInsert
6841
6842
  #disposeAfter
6842
6843
  #fetchMethod
6843
6844
  #memoMethod
@@ -6919,6 +6920,7 @@ function requireCommonjs$3() {
6919
6920
  #hasDispose
6920
6921
  #hasFetchMethod
6921
6922
  #hasDisposeAfter
6923
+ #hasOnInsert
6922
6924
  /**
6923
6925
  * Do not call this method unless you need to inspect the
6924
6926
  * inner workings of the cache. If anything returned by this
@@ -6996,6 +6998,12 @@ function requireCommonjs$3() {
6996
6998
  get dispose() {
6997
6999
  return this.#dispose
6998
7000
  }
7001
+ /**
7002
+ * {@link LRUCache.OptionsBase.onInsert} (read-only)
7003
+ */
7004
+ get onInsert() {
7005
+ return this.#onInsert
7006
+ }
6999
7007
  /**
7000
7008
  * {@link LRUCache.OptionsBase.disposeAfter} (read-only)
7001
7009
  */
@@ -7012,6 +7020,7 @@ function requireCommonjs$3() {
7012
7020
  updateAgeOnHas,
7013
7021
  allowStale,
7014
7022
  dispose,
7023
+ onInsert,
7015
7024
  disposeAfter,
7016
7025
  noDisposeOnSet,
7017
7026
  noUpdateTTL,
@@ -7069,6 +7078,9 @@ function requireCommonjs$3() {
7069
7078
  if (typeof dispose === 'function') {
7070
7079
  this.#dispose = dispose
7071
7080
  }
7081
+ if (typeof onInsert === 'function') {
7082
+ this.#onInsert = onInsert
7083
+ }
7072
7084
  if (typeof disposeAfter === 'function') {
7073
7085
  this.#disposeAfter = disposeAfter
7074
7086
  this.#disposed = []
@@ -7077,6 +7089,7 @@ function requireCommonjs$3() {
7077
7089
  this.#disposed = undefined
7078
7090
  }
7079
7091
  this.#hasDispose = !!this.#dispose
7092
+ this.#hasOnInsert = !!this.#onInsert
7080
7093
  this.#hasDisposeAfter = !!this.#disposeAfter
7081
7094
  this.noDisposeOnSet = !!noDisposeOnSet
7082
7095
  this.noUpdateTTL = !!noUpdateTTL
@@ -7522,7 +7535,7 @@ function requireCommonjs$3() {
7522
7535
  }
7523
7536
  /**
7524
7537
  * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
7525
- * passed to {@link LRLUCache#load}.
7538
+ * passed to {@link LRUCache#load}.
7526
7539
  *
7527
7540
  * The `start` fields are calculated relative to a portable `Date.now()`
7528
7541
  * timestamp, even if `performance.now()` is available.
@@ -7669,6 +7682,9 @@ function requireCommonjs$3() {
7669
7682
  status.set = 'add'
7670
7683
  }
7671
7684
  noUpdateTTL = false
7685
+ if (this.#hasOnInsert) {
7686
+ this.#onInsert?.(v, k, 'add')
7687
+ }
7672
7688
  } else {
7673
7689
  // update
7674
7690
  this.#moveToTail(index)
@@ -7709,6 +7725,9 @@ function requireCommonjs$3() {
7709
7725
  } else if (status) {
7710
7726
  status.set = 'update'
7711
7727
  }
7728
+ if (this.#hasOnInsert) {
7729
+ this.onInsert?.(v, k, v === oldVal ? 'update' : 'replace')
7730
+ }
7712
7731
  }
7713
7732
  if (ttl !== 0 && !this.#ttls) {
7714
7733
  this.#initializeTTLTracking()
@@ -8303,8 +8322,8 @@ function requireCommonjs$3() {
8303
8322
  }
8304
8323
  }
8305
8324
  }
8306
- commonjs$3.LRUCache = LRUCache
8307
- return commonjs$3
8325
+ commonjs$6.LRUCache = LRUCache
8326
+ return commonjs$6
8308
8327
  }
8309
8328
 
8310
8329
  let hasRequiredMemoization
@@ -8314,7 +8333,7 @@ function requireMemoization() {
8314
8333
  }
8315
8334
  hasRequiredMemoization = 1
8316
8335
  ;(function (module) {
8317
- const { LRUCache } = /*@__PURE__*/ requireCommonjs$3()
8336
+ const { LRUCache } = /*@__PURE__*/ requireCommonjs$6()
8318
8337
  const MEMOIZED = new LRUCache({
8319
8338
  max: 500,
8320
8339
  maxSize: 50 * 1024 * 1024,
@@ -8389,7 +8408,7 @@ function requireLib$1() {
8389
8408
  return lib
8390
8409
  }
8391
8410
  hasRequiredLib$1 = 1
8392
- const { Minipass } = requireCommonjs$4()
8411
+ const { Minipass } = requireCommonjs$7()
8393
8412
  const EE = require$$0$1.EventEmitter
8394
8413
  const fs = require$$2$2
8395
8414
  const writev = fs.writev
@@ -8989,7 +9008,7 @@ function requireGet() {
8989
9008
  hasRequiredGet = 1
8990
9009
  ;(function (module) {
8991
9010
  const Collect = requireMinipassCollect()
8992
- const { Minipass } = requireCommonjs$4()
9011
+ const { Minipass } = requireCommonjs$7()
8993
9012
  const Pipeline = requireMinipassPipeline()
8994
9013
  const index = requireEntryIndex()
8995
9014
  const memo = requireMemoization()
@@ -9904,7 +9923,7 @@ function requireWrite() {
9904
9923
  const contentPath = requirePath()
9905
9924
  const fs = require$$0$5
9906
9925
  const { moveFile } = requireLib$2()
9907
- const { Minipass } = requireCommonjs$4()
9926
+ const { Minipass } = requireCommonjs$7()
9908
9927
  const Pipeline = requireMinipassPipeline()
9909
9928
  const Flush = requireMinipassFlush()
9910
9929
  const path = require$$0$3
@@ -10207,136 +10226,149 @@ function requirePut() {
10207
10226
 
10208
10227
  const rm = { exports: {} }
10209
10228
 
10210
- const commonjs$2 = {}
10229
+ const commonjs$5 = {}
10211
10230
 
10212
- const commonjs$1 = {}
10231
+ const commonjs$4 = {}
10232
+
10233
+ const commonjs$3 = {}
10234
+
10235
+ const commonjs$2 = {}
10213
10236
 
10214
- let balancedMatch
10215
- let hasRequiredBalancedMatch
10216
- function requireBalancedMatch() {
10217
- if (hasRequiredBalancedMatch) {
10218
- return balancedMatch
10237
+ let hasRequiredCommonjs$5
10238
+ function requireCommonjs$5() {
10239
+ if (hasRequiredCommonjs$5) {
10240
+ return commonjs$2
10219
10241
  }
10220
- hasRequiredBalancedMatch = 1
10221
- balancedMatch = balanced
10222
- function balanced(a, b, str) {
10223
- if (a instanceof RegExp) {
10224
- a = maybeMatch(a, str)
10225
- }
10226
- if (b instanceof RegExp) {
10227
- b = maybeMatch(b, str)
10242
+ hasRequiredCommonjs$5 = 1
10243
+ ;(function (exports) {
10244
+ Object.defineProperty(exports, '__esModule', {
10245
+ value: true
10246
+ })
10247
+ exports.range = exports.balanced = void 0
10248
+ const balanced = (a, b, str) => {
10249
+ const ma = a instanceof RegExp ? maybeMatch(a, str) : a
10250
+ const mb = b instanceof RegExp ? maybeMatch(b, str) : b
10251
+ const r = ma !== null && mb != null && (0, exports.range)(ma, mb, str)
10252
+ return (
10253
+ r && {
10254
+ start: r[0],
10255
+ end: r[1],
10256
+ pre: str.slice(0, r[0]),
10257
+ body: str.slice(r[0] + ma.length, r[1]),
10258
+ post: str.slice(r[1] + mb.length)
10259
+ }
10260
+ )
10228
10261
  }
10229
- const r = range(a, b, str)
10230
- return (
10231
- r && {
10232
- start: r[0],
10233
- end: r[1],
10234
- pre: str.slice(0, r[0]),
10235
- body: str.slice(r[0] + a.length, r[1]),
10236
- post: str.slice(r[1] + b.length)
10237
- }
10238
- )
10239
- }
10240
- function maybeMatch(reg, str) {
10241
- const m = str.match(reg)
10242
- return m ? m[0] : null
10243
- }
10244
- balanced.range = range
10245
- function range(a, b, str) {
10246
- let begs, beg, left, right, result
10247
- let ai = str.indexOf(a)
10248
- let bi = str.indexOf(b, ai + 1)
10249
- let i = ai
10250
- if (ai >= 0 && bi > 0) {
10251
- if (a === b) {
10252
- return [ai, bi]
10253
- }
10254
- begs = []
10255
- left = str.length
10256
- while (i >= 0 && !result) {
10257
- if (i == ai) {
10258
- begs.push(i)
10259
- ai = str.indexOf(a, i + 1)
10260
- } else if (begs.length == 1) {
10261
- result = [begs.pop(), bi]
10262
- } else {
10263
- beg = begs.pop()
10264
- if (beg < left) {
10265
- left = beg
10266
- right = bi
10262
+ exports.balanced = balanced
10263
+ const maybeMatch = (reg, str) => {
10264
+ const m = str.match(reg)
10265
+ return m ? m[0] : null
10266
+ }
10267
+ const range = (a, b, str) => {
10268
+ let begs,
10269
+ beg,
10270
+ left,
10271
+ right = undefined,
10272
+ result
10273
+ let ai = str.indexOf(a)
10274
+ let bi = str.indexOf(b, ai + 1)
10275
+ let i = ai
10276
+ if (ai >= 0 && bi > 0) {
10277
+ if (a === b) {
10278
+ return [ai, bi]
10279
+ }
10280
+ begs = []
10281
+ left = str.length
10282
+ while (i >= 0 && !result) {
10283
+ if (i === ai) {
10284
+ begs.push(i)
10285
+ ai = str.indexOf(a, i + 1)
10286
+ } else if (begs.length === 1) {
10287
+ const r = begs.pop()
10288
+ if (r !== undefined) {
10289
+ result = [r, bi]
10290
+ }
10291
+ } else {
10292
+ beg = begs.pop()
10293
+ if (beg !== undefined && beg < left) {
10294
+ left = beg
10295
+ right = bi
10296
+ }
10297
+ bi = str.indexOf(b, i + 1)
10267
10298
  }
10268
- bi = str.indexOf(b, i + 1)
10299
+ i = ai < bi && ai >= 0 ? ai : bi
10300
+ }
10301
+ if (begs.length && right !== undefined) {
10302
+ result = [left, right]
10269
10303
  }
10270
- i = ai < bi && ai >= 0 ? ai : bi
10271
- }
10272
- if (begs.length) {
10273
- result = [left, right]
10274
10304
  }
10305
+ return result
10275
10306
  }
10276
- return result
10277
- }
10278
- return balancedMatch
10307
+ exports.range = range
10308
+ })(commonjs$2)
10309
+ return commonjs$2
10279
10310
  }
10280
10311
 
10281
- let braceExpansion
10282
- let hasRequiredBraceExpansion
10283
- function requireBraceExpansion() {
10284
- if (hasRequiredBraceExpansion) {
10285
- return braceExpansion
10312
+ let hasRequiredCommonjs$4
10313
+ function requireCommonjs$4() {
10314
+ if (hasRequiredCommonjs$4) {
10315
+ return commonjs$3
10286
10316
  }
10287
- hasRequiredBraceExpansion = 1
10288
- const balanced = requireBalancedMatch()
10289
- braceExpansion = expandTop
10317
+ hasRequiredCommonjs$4 = 1
10318
+ Object.defineProperty(commonjs$3, '__esModule', {
10319
+ value: true
10320
+ })
10321
+ commonjs$3.expand = expand
10322
+ const balanced_match_1 = requireCommonjs$5()
10290
10323
  const escSlash = '\0SLASH' + Math.random() + '\0'
10291
10324
  const escOpen = '\0OPEN' + Math.random() + '\0'
10292
10325
  const escClose = '\0CLOSE' + Math.random() + '\0'
10293
10326
  const escComma = '\0COMMA' + Math.random() + '\0'
10294
10327
  const escPeriod = '\0PERIOD' + Math.random() + '\0'
10328
+ const escSlashPattern = new RegExp(escSlash, 'g')
10329
+ const escOpenPattern = new RegExp(escOpen, 'g')
10330
+ const escClosePattern = new RegExp(escClose, 'g')
10331
+ const escCommaPattern = new RegExp(escComma, 'g')
10332
+ const escPeriodPattern = new RegExp(escPeriod, 'g')
10333
+ const slashPattern = /\\\\/g
10334
+ const openPattern = /\\{/g
10335
+ const closePattern = /\\}/g
10336
+ const commaPattern = /\\,/g
10337
+ const periodPattern = /\\./g
10295
10338
  function numeric(str) {
10296
- return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0)
10339
+ return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0)
10297
10340
  }
10298
10341
  function escapeBraces(str) {
10299
10342
  return str
10300
- .split('\\\\')
10301
- .join(escSlash)
10302
- .split('\\{')
10303
- .join(escOpen)
10304
- .split('\\}')
10305
- .join(escClose)
10306
- .split('\\,')
10307
- .join(escComma)
10308
- .split('\\.')
10309
- .join(escPeriod)
10343
+ .replace(slashPattern, escSlash)
10344
+ .replace(openPattern, escOpen)
10345
+ .replace(closePattern, escClose)
10346
+ .replace(commaPattern, escComma)
10347
+ .replace(periodPattern, escPeriod)
10310
10348
  }
10311
10349
  function unescapeBraces(str) {
10312
10350
  return str
10313
- .split(escSlash)
10314
- .join('\\')
10315
- .split(escOpen)
10316
- .join('{')
10317
- .split(escClose)
10318
- .join('}')
10319
- .split(escComma)
10320
- .join(',')
10321
- .split(escPeriod)
10322
- .join('.')
10323
- }
10324
-
10325
- // Basically just str.split(","), but handling cases
10326
- // where we have nested braced sections, which should be
10327
- // treated as individual members, like {a,{b,c},d}
10351
+ .replace(escSlashPattern, '\\')
10352
+ .replace(escOpenPattern, '{')
10353
+ .replace(escClosePattern, '}')
10354
+ .replace(escCommaPattern, ',')
10355
+ .replace(escPeriodPattern, '.')
10356
+ }
10357
+ /**
10358
+ * Basically just str.split(","), but handling cases
10359
+ * where we have nested braced sections, which should be
10360
+ * treated as individual members, like {a,{b,c},d}
10361
+ */
10328
10362
  function parseCommaParts(str) {
10329
10363
  if (!str) {
10330
10364
  return ['']
10331
10365
  }
10332
10366
  const parts = []
10333
- const m = balanced('{', '}', str)
10367
+ const m = (0, balanced_match_1.balanced)('{', '}', str)
10334
10368
  if (!m) {
10335
10369
  return str.split(',')
10336
10370
  }
10337
- const pre = m.pre
10338
- const body = m.body
10339
- const post = m.post
10371
+ const { pre, body, post } = m
10340
10372
  const p = pre.split(',')
10341
10373
  p[p.length - 1] += '{' + body + '}'
10342
10374
  const postParts = parseCommaParts(post)
@@ -10347,21 +10379,20 @@ function requireBraceExpansion() {
10347
10379
  parts.push.apply(parts, p)
10348
10380
  return parts
10349
10381
  }
10350
- function expandTop(str) {
10382
+ function expand(str) {
10351
10383
  if (!str) {
10352
10384
  return []
10353
10385
  }
10354
-
10355
10386
  // I don't know why Bash 4.3 does this, but it does.
10356
10387
  // Anything starting with {} will have the first two bytes preserved
10357
10388
  // but *only* at the top level, so {},a}b will not expand to anything,
10358
10389
  // but a{},b}c will be expanded to [a}c,abc].
10359
10390
  // One could argue that this is a bug in Bash, but since the goal of
10360
10391
  // this module is to match Bash's rules, we escape a leading {}
10361
- if (str.substr(0, 2) === '{}') {
10362
- str = '\\{\\}' + str.substr(2)
10392
+ if (str.slice(0, 2) === '{}') {
10393
+ str = '\\{\\}' + str.slice(2)
10363
10394
  }
10364
- return expand(escapeBraces(str), true).map(unescapeBraces)
10395
+ return expand_(escapeBraces(str), true).map(unescapeBraces)
10365
10396
  }
10366
10397
  function embrace(str) {
10367
10398
  return '{' + str + '}'
@@ -10375,19 +10406,19 @@ function requireBraceExpansion() {
10375
10406
  function gte(i, y) {
10376
10407
  return i >= y
10377
10408
  }
10378
- function expand(str, isTop) {
10409
+ function expand_(str, isTop) {
10410
+ /** @type {string[]} */
10379
10411
  const expansions = []
10380
- const m = balanced('{', '}', str)
10412
+ const m = (0, balanced_match_1.balanced)('{', '}', str)
10381
10413
  if (!m) {
10382
10414
  return [str]
10383
10415
  }
10384
-
10385
10416
  // no need to expand pre, since it is guaranteed to be free of brace-sets
10386
10417
  const pre = m.pre
10387
- const post = m.post.length ? expand(m.post, false) : ['']
10388
- if (m.pre.endsWith('\u0024' /*'$'*/)) {
10389
- for (var k = 0; k < post.length; k++) {
10390
- var expansion = pre + '{' + m.body + '}' + post[k]
10418
+ const post = m.post.length ? expand_(m.post, false) : ['']
10419
+ if (/\$$/.test(m.pre)) {
10420
+ for (let k = 0; k < post.length; k++) {
10421
+ const expansion = pre + '{' + m.body + '}' + post[k]
10391
10422
  expansions.push(expansion)
10392
10423
  }
10393
10424
  } else {
@@ -10399,9 +10430,9 @@ function requireBraceExpansion() {
10399
10430
  const isOptions = m.body.indexOf(',') >= 0
10400
10431
  if (!isSequence && !isOptions) {
10401
10432
  // {a},b}
10402
- if (m.post.match(/,.*\}/)) {
10433
+ if (m.post.match(/,(?!,).*\}/)) {
10403
10434
  str = m.pre + '{' + m.body + escClose + m.post
10404
- return expand(str)
10435
+ return expand_(str)
10405
10436
  }
10406
10437
  return [str]
10407
10438
  }
@@ -10410,25 +10441,26 @@ function requireBraceExpansion() {
10410
10441
  n = m.body.split(/\.\./)
10411
10442
  } else {
10412
10443
  n = parseCommaParts(m.body)
10413
- if (n.length === 1) {
10444
+ if (n.length === 1 && n[0] !== undefined) {
10414
10445
  // x{{a,b}}y ==> x{a}y x{b}y
10415
- n = expand(n[0], false).map(embrace)
10446
+ n = expand_(n[0], false).map(embrace)
10447
+ //XXX is this necessary? Can't seem to hit it in tests.
10448
+ /* c8 ignore start */
10416
10449
  if (n.length === 1) {
10417
- return post.map(function (p) {
10418
- return m.pre + n[0] + p
10419
- })
10450
+ return post.map(p => m.pre + n[0] + p)
10420
10451
  }
10452
+ /* c8 ignore stop */
10421
10453
  }
10422
10454
  }
10423
-
10424
10455
  // at this point, n is the parts, and we know it's not a comma set
10425
10456
  // with a single entry.
10426
10457
  let N
10427
- if (isSequence) {
10458
+ if (isSequence && n[0] !== undefined && n[1] !== undefined) {
10428
10459
  const x = numeric(n[0])
10429
10460
  const y = numeric(n[1])
10430
10461
  const width = Math.max(n[0].length, n[1].length)
10431
- let incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1
10462
+ let incr =
10463
+ n.length === 3 && n[2] !== undefined ? Math.abs(numeric(n[2])) : 1
10432
10464
  let test = lte
10433
10465
  const reverse = y < x
10434
10466
  if (reverse) {
@@ -10462,13 +10494,13 @@ function requireBraceExpansion() {
10462
10494
  }
10463
10495
  } else {
10464
10496
  N = []
10465
- for (var j = 0; j < n.length; j++) {
10466
- N.push.apply(N, expand(n[j], false))
10497
+ for (let j = 0; j < n.length; j++) {
10498
+ N.push.apply(N, expand_(n[j], false))
10467
10499
  }
10468
10500
  }
10469
- for (var j = 0; j < N.length; j++) {
10470
- for (var k = 0; k < post.length; k++) {
10471
- var expansion = pre + N[j] + post[k]
10501
+ for (let j = 0; j < N.length; j++) {
10502
+ for (let k = 0; k < post.length; k++) {
10503
+ const expansion = pre + N[j] + post[k]
10472
10504
  if (!isTop || isSequence || expansion) {
10473
10505
  expansions.push(expansion)
10474
10506
  }
@@ -10477,7 +10509,7 @@ function requireBraceExpansion() {
10477
10509
  }
10478
10510
  return expansions
10479
10511
  }
10480
- return braceExpansion
10512
+ return commonjs$3
10481
10513
  }
10482
10514
 
10483
10515
  const assertValidPattern = {}
@@ -11381,22 +11413,13 @@ function require_escape() {
11381
11413
  return _escape
11382
11414
  }
11383
11415
 
11384
- let hasRequiredCommonjs$2
11385
- function requireCommonjs$2() {
11386
- if (hasRequiredCommonjs$2) {
11387
- return commonjs$1
11416
+ let hasRequiredCommonjs$3
11417
+ function requireCommonjs$3() {
11418
+ if (hasRequiredCommonjs$3) {
11419
+ return commonjs$4
11388
11420
  }
11389
- hasRequiredCommonjs$2 = 1
11421
+ hasRequiredCommonjs$3 = 1
11390
11422
  ;(function (exports) {
11391
- const __importDefault =
11392
- (this && this.__importDefault) ||
11393
- function (mod) {
11394
- return mod && mod.__esModule
11395
- ? mod
11396
- : {
11397
- default: mod
11398
- }
11399
- }
11400
11423
  Object.defineProperty(exports, '__esModule', {
11401
11424
  value: true
11402
11425
  })
@@ -11413,7 +11436,7 @@ function requireCommonjs$2() {
11413
11436
  exports.sep =
11414
11437
  exports.minimatch =
11415
11438
  void 0
11416
- const brace_expansion_1 = __importDefault(requireBraceExpansion())
11439
+ const brace_expansion_1 = requireCommonjs$4()
11417
11440
  const assert_valid_pattern_js_1 = requireAssertValidPattern()
11418
11441
  const ast_js_1 = requireAst()
11419
11442
  const escape_js_1 = require_escape()
@@ -11581,7 +11604,7 @@ function requireCommonjs$2() {
11581
11604
  // shortcut. no need to expand.
11582
11605
  return [pattern]
11583
11606
  }
11584
- return (0, brace_expansion_1.default)(pattern)
11607
+ return (0, brace_expansion_1.expand)(pattern)
11585
11608
  }
11586
11609
  exports.braceExpand = braceExpand
11587
11610
  exports.minimatch.braceExpand = exports.braceExpand
@@ -12099,11 +12122,11 @@ function requireCommonjs$2() {
12099
12122
  pattern
12100
12123
  })
12101
12124
  this.debug('matchOne', file.length, pattern.length)
12102
- let fi = 0,
12103
- pi = 0,
12104
- fl = file.length,
12105
- pl = pattern.length
12106
- for (; fi < fl && pi < pl; fi++, pi++) {
12125
+ for (
12126
+ var fi = 0, pi = 0, fl = file.length, pl = pattern.length;
12127
+ fi < fl && pi < pl;
12128
+ fi++, pi++
12129
+ ) {
12107
12130
  this.debug('matchOne loop')
12108
12131
  const p = pattern[pi]
12109
12132
  const f = file[fi]
@@ -12484,118 +12507,1774 @@ function requireCommonjs$2() {
12484
12507
  exports.minimatch.Minimatch = Minimatch
12485
12508
  exports.minimatch.escape = escape_js_1.escape
12486
12509
  exports.minimatch.unescape = unescape_js_1.unescape
12487
- })(commonjs$1)
12488
- return commonjs$1
12510
+ })(commonjs$4)
12511
+ return commonjs$4
12489
12512
  }
12490
12513
 
12491
12514
  const glob = {}
12492
12515
 
12516
+ const commonjs$1 = {}
12517
+
12493
12518
  const commonjs = {}
12494
12519
 
12495
- let hasRequiredCommonjs$1
12496
- function requireCommonjs$1() {
12497
- if (hasRequiredCommonjs$1) {
12520
+ let hasRequiredCommonjs$2
12521
+ function requireCommonjs$2() {
12522
+ if (hasRequiredCommonjs$2) {
12498
12523
  return commonjs
12499
12524
  }
12500
- hasRequiredCommonjs$1 = 1
12501
- const __createBinding =
12502
- (this && this.__createBinding) ||
12503
- (Object.create
12504
- ? function (o, m, k, k2) {
12505
- if (k2 === undefined) {
12506
- k2 = k
12507
- }
12508
- let desc = Object.getOwnPropertyDescriptor(m, k)
12509
- if (
12510
- !desc ||
12511
- ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)
12512
- ) {
12513
- desc = {
12514
- enumerable: true,
12515
- get: function () {
12516
- return m[k]
12517
- }
12518
- }
12519
- }
12520
- Object.defineProperty(o, k2, desc)
12525
+ hasRequiredCommonjs$2 = 1
12526
+ /**
12527
+ * @module LRUCache
12528
+ */
12529
+ Object.defineProperty(commonjs, '__esModule', {
12530
+ value: true
12531
+ })
12532
+ commonjs.LRUCache = void 0
12533
+ const perf =
12534
+ typeof performance === 'object' &&
12535
+ performance &&
12536
+ typeof performance.now === 'function'
12537
+ ? performance
12538
+ : Date
12539
+ const warned = new Set()
12540
+ /* c8 ignore start */
12541
+ const PROCESS = typeof process === 'object' && !!process ? process : {}
12542
+ /* c8 ignore start */
12543
+ const emitWarning = (msg, type, code, fn) => {
12544
+ typeof PROCESS.emitWarning === 'function'
12545
+ ? PROCESS.emitWarning(msg, type, code, fn)
12546
+ : console.error(`[${code}] ${type}: ${msg}`)
12547
+ }
12548
+ let AC = globalThis.AbortController
12549
+ let AS = globalThis.AbortSignal
12550
+ /* c8 ignore start */
12551
+ if (typeof AC === 'undefined') {
12552
+ //@ts-ignore
12553
+ AS = class AbortSignal {
12554
+ onabort
12555
+ _onabort = []
12556
+ reason
12557
+ aborted = false
12558
+ addEventListener(_, fn) {
12559
+ this._onabort.push(fn)
12560
+ }
12561
+ }
12562
+ //@ts-ignore
12563
+ AC = class AbortController {
12564
+ constructor() {
12565
+ warnACPolyfill()
12566
+ }
12567
+ signal = new AS()
12568
+ abort(reason) {
12569
+ if (this.signal.aborted) {
12570
+ return
12521
12571
  }
12522
- : function (o, m, k, k2) {
12523
- if (k2 === undefined) {
12524
- k2 = k
12525
- }
12526
- o[k2] = m[k]
12527
- })
12528
- const __setModuleDefault =
12529
- (this && this.__setModuleDefault) ||
12530
- (Object.create
12531
- ? function (o, v) {
12532
- Object.defineProperty(o, 'default', {
12533
- enumerable: true,
12534
- value: v
12535
- })
12572
+ //@ts-ignore
12573
+ this.signal.reason = reason
12574
+ //@ts-ignore
12575
+ this.signal.aborted = true
12576
+ //@ts-ignore
12577
+ for (const fn of this.signal._onabort) {
12578
+ fn(reason)
12536
12579
  }
12537
- : function (o, v) {
12538
- o['default'] = v
12539
- })
12540
- const __importStar =
12541
- (this && this.__importStar) ||
12542
- function (mod) {
12543
- if (mod && mod.__esModule) {
12544
- return mod
12545
- }
12546
- const result = {}
12547
- if (mod != null) {
12548
- for (var k in mod)
12549
- if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k))
12550
- __createBinding(result, mod, k)
12580
+ this.signal.onabort?.(reason)
12551
12581
  }
12552
- __setModuleDefault(result, mod)
12553
- return result
12554
12582
  }
12555
- Object.defineProperty(commonjs, '__esModule', {
12556
- value: true
12557
- })
12558
- commonjs.PathScurry =
12559
- commonjs.Path =
12560
- commonjs.PathScurryDarwin =
12561
- commonjs.PathScurryPosix =
12562
- commonjs.PathScurryWin32 =
12563
- commonjs.PathScurryBase =
12564
- commonjs.PathPosix =
12565
- commonjs.PathWin32 =
12566
- commonjs.PathBase =
12567
- commonjs.ChildrenCache =
12568
- commonjs.ResolveCache =
12569
- void 0
12570
- const lru_cache_1 = /*@__PURE__*/ requireCommonjs$3()
12571
- const node_path_1 = require$$1$3
12572
- const node_url_1 = require$$2$3
12573
- const fs_1 = require$$2$2
12574
- const actualFS = __importStar(require$$4$1)
12575
- const realpathSync = fs_1.realpathSync.native
12576
- // TODO: test perf of fs/promises realpath vs realpathCB,
12577
- // since the promises one uses realpath.native
12578
- const promises_1 = require$$5
12579
- const minipass_1 = requireCommonjs$4()
12580
- const defaultFS = {
12581
- lstatSync: fs_1.lstatSync,
12582
- readdir: fs_1.readdir,
12583
- readdirSync: fs_1.readdirSync,
12584
- readlinkSync: fs_1.readlinkSync,
12585
- realpathSync,
12586
- promises: {
12587
- lstat: promises_1.lstat,
12588
- readdir: promises_1.readdir,
12589
- readlink: promises_1.readlink,
12590
- realpath: promises_1.realpath
12583
+ let printACPolyfillWarning =
12584
+ PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1'
12585
+ const warnACPolyfill = () => {
12586
+ if (!printACPolyfillWarning) {
12587
+ return
12588
+ }
12589
+ printACPolyfillWarning = false
12590
+ emitWarning(
12591
+ 'AbortController is not defined. If using lru-cache in ' +
12592
+ 'node 14, load an AbortController polyfill from the ' +
12593
+ '`node-abort-controller` package. A minimal polyfill is ' +
12594
+ 'provided for use by LRUCache.fetch(), but it should not be ' +
12595
+ 'relied upon in other contexts (eg, passing it to other APIs that ' +
12596
+ 'use AbortController/AbortSignal might have undesirable effects). ' +
12597
+ 'You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.',
12598
+ 'NO_ABORT_CONTROLLER',
12599
+ 'ENOTSUP',
12600
+ warnACPolyfill
12601
+ )
12591
12602
  }
12592
12603
  }
12593
- // if they just gave us require('fs') then use our default
12594
- const fsFromOption = fsOption =>
12595
- !fsOption || fsOption === defaultFS || fsOption === actualFS
12596
- ? defaultFS
12597
- : {
12598
- ...defaultFS,
12604
+ /* c8 ignore stop */
12605
+ const shouldWarn = code => !warned.has(code)
12606
+ const isPosInt = n => n && n === Math.floor(n) && n > 0 && isFinite(n)
12607
+ /* c8 ignore start */
12608
+ // This is a little bit ridiculous, tbh.
12609
+ // The maximum array length is 2^32-1 or thereabouts on most JS impls.
12610
+ // And well before that point, you're caching the entire world, I mean,
12611
+ // that's ~32GB of just integers for the next/prev links, plus whatever
12612
+ // else to hold that many keys and values. Just filling the memory with
12613
+ // zeroes at init time is brutal when you get that big.
12614
+ // But why not be complete?
12615
+ // Maybe in the future, these limits will have expanded.
12616
+ const getUintArray = max =>
12617
+ !isPosInt(max)
12618
+ ? null
12619
+ : max <= Math.pow(2, 8)
12620
+ ? Uint8Array
12621
+ : max <= Math.pow(2, 16)
12622
+ ? Uint16Array
12623
+ : max <= Math.pow(2, 32)
12624
+ ? Uint32Array
12625
+ : max <= Number.MAX_SAFE_INTEGER
12626
+ ? ZeroArray
12627
+ : null
12628
+ /* c8 ignore stop */
12629
+ class ZeroArray extends Array {
12630
+ constructor(size) {
12631
+ super(size)
12632
+ this.fill(0)
12633
+ }
12634
+ }
12635
+ class Stack {
12636
+ heap
12637
+ length
12638
+ // private constructor
12639
+ static #constructing = false
12640
+ static create(max) {
12641
+ const HeapCls = getUintArray(max)
12642
+ if (!HeapCls) {
12643
+ return []
12644
+ }
12645
+ Stack.#constructing = true
12646
+ const s = new Stack(max, HeapCls)
12647
+ Stack.#constructing = false
12648
+ return s
12649
+ }
12650
+ constructor(max, HeapCls) {
12651
+ /* c8 ignore start */
12652
+ if (!Stack.#constructing) {
12653
+ throw new TypeError('instantiate Stack using Stack.create(n)')
12654
+ }
12655
+ /* c8 ignore stop */
12656
+ this.heap = new HeapCls(max)
12657
+ this.length = 0
12658
+ }
12659
+ push(n) {
12660
+ this.heap[this.length++] = n
12661
+ }
12662
+ pop() {
12663
+ return this.heap[--this.length]
12664
+ }
12665
+ }
12666
+ /**
12667
+ * Default export, the thing you're using this module to get.
12668
+ *
12669
+ * The `K` and `V` types define the key and value types, respectively. The
12670
+ * optional `FC` type defines the type of the `context` object passed to
12671
+ * `cache.fetch()` and `cache.memo()`.
12672
+ *
12673
+ * Keys and values **must not** be `null` or `undefined`.
12674
+ *
12675
+ * All properties from the options object (with the exception of `max`,
12676
+ * `maxSize`, `fetchMethod`, `memoMethod`, `dispose` and `disposeAfter`) are
12677
+ * added as normal public members. (The listed options are read-only getters.)
12678
+ *
12679
+ * Changing any of these will alter the defaults for subsequent method calls.
12680
+ */
12681
+ class LRUCache {
12682
+ // options that cannot be changed without disaster
12683
+ #max
12684
+ #maxSize
12685
+ #dispose
12686
+ #onInsert
12687
+ #disposeAfter
12688
+ #fetchMethod
12689
+ #memoMethod
12690
+ /**
12691
+ * {@link LRUCache.OptionsBase.ttl}
12692
+ */
12693
+ ttl
12694
+ /**
12695
+ * {@link LRUCache.OptionsBase.ttlResolution}
12696
+ */
12697
+ ttlResolution
12698
+ /**
12699
+ * {@link LRUCache.OptionsBase.ttlAutopurge}
12700
+ */
12701
+ ttlAutopurge
12702
+ /**
12703
+ * {@link LRUCache.OptionsBase.updateAgeOnGet}
12704
+ */
12705
+ updateAgeOnGet
12706
+ /**
12707
+ * {@link LRUCache.OptionsBase.updateAgeOnHas}
12708
+ */
12709
+ updateAgeOnHas
12710
+ /**
12711
+ * {@link LRUCache.OptionsBase.allowStale}
12712
+ */
12713
+ allowStale
12714
+ /**
12715
+ * {@link LRUCache.OptionsBase.noDisposeOnSet}
12716
+ */
12717
+ noDisposeOnSet
12718
+ /**
12719
+ * {@link LRUCache.OptionsBase.noUpdateTTL}
12720
+ */
12721
+ noUpdateTTL
12722
+ /**
12723
+ * {@link LRUCache.OptionsBase.maxEntrySize}
12724
+ */
12725
+ maxEntrySize
12726
+ /**
12727
+ * {@link LRUCache.OptionsBase.sizeCalculation}
12728
+ */
12729
+ sizeCalculation
12730
+ /**
12731
+ * {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
12732
+ */
12733
+ noDeleteOnFetchRejection
12734
+ /**
12735
+ * {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
12736
+ */
12737
+ noDeleteOnStaleGet
12738
+ /**
12739
+ * {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
12740
+ */
12741
+ allowStaleOnFetchAbort
12742
+ /**
12743
+ * {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
12744
+ */
12745
+ allowStaleOnFetchRejection
12746
+ /**
12747
+ * {@link LRUCache.OptionsBase.ignoreFetchAbort}
12748
+ */
12749
+ ignoreFetchAbort
12750
+ // computed properties
12751
+ #size
12752
+ #calculatedSize
12753
+ #keyMap
12754
+ #keyList
12755
+ #valList
12756
+ #next
12757
+ #prev
12758
+ #head
12759
+ #tail
12760
+ #free
12761
+ #disposed
12762
+ #sizes
12763
+ #starts
12764
+ #ttls
12765
+ #hasDispose
12766
+ #hasFetchMethod
12767
+ #hasDisposeAfter
12768
+ #hasOnInsert
12769
+ /**
12770
+ * Do not call this method unless you need to inspect the
12771
+ * inner workings of the cache. If anything returned by this
12772
+ * object is modified in any way, strange breakage may occur.
12773
+ *
12774
+ * These fields are private for a reason!
12775
+ *
12776
+ * @internal
12777
+ */
12778
+ static unsafeExposeInternals(c) {
12779
+ return {
12780
+ // properties
12781
+ starts: c.#starts,
12782
+ ttls: c.#ttls,
12783
+ sizes: c.#sizes,
12784
+ keyMap: c.#keyMap,
12785
+ keyList: c.#keyList,
12786
+ valList: c.#valList,
12787
+ next: c.#next,
12788
+ prev: c.#prev,
12789
+ get head() {
12790
+ return c.#head
12791
+ },
12792
+ get tail() {
12793
+ return c.#tail
12794
+ },
12795
+ free: c.#free,
12796
+ // methods
12797
+ isBackgroundFetch: p => c.#isBackgroundFetch(p),
12798
+ backgroundFetch: (k, index, options, context) =>
12799
+ c.#backgroundFetch(k, index, options, context),
12800
+ moveToTail: index => c.#moveToTail(index),
12801
+ indexes: options => c.#indexes(options),
12802
+ rindexes: options => c.#rindexes(options),
12803
+ isStale: index => c.#isStale(index)
12804
+ }
12805
+ }
12806
+ // Protected read-only members
12807
+ /**
12808
+ * {@link LRUCache.OptionsBase.max} (read-only)
12809
+ */
12810
+ get max() {
12811
+ return this.#max
12812
+ }
12813
+ /**
12814
+ * {@link LRUCache.OptionsBase.maxSize} (read-only)
12815
+ */
12816
+ get maxSize() {
12817
+ return this.#maxSize
12818
+ }
12819
+ /**
12820
+ * The total computed size of items in the cache (read-only)
12821
+ */
12822
+ get calculatedSize() {
12823
+ return this.#calculatedSize
12824
+ }
12825
+ /**
12826
+ * The number of items stored in the cache (read-only)
12827
+ */
12828
+ get size() {
12829
+ return this.#size
12830
+ }
12831
+ /**
12832
+ * {@link LRUCache.OptionsBase.fetchMethod} (read-only)
12833
+ */
12834
+ get fetchMethod() {
12835
+ return this.#fetchMethod
12836
+ }
12837
+ get memoMethod() {
12838
+ return this.#memoMethod
12839
+ }
12840
+ /**
12841
+ * {@link LRUCache.OptionsBase.dispose} (read-only)
12842
+ */
12843
+ get dispose() {
12844
+ return this.#dispose
12845
+ }
12846
+ /**
12847
+ * {@link LRUCache.OptionsBase.onInsert} (read-only)
12848
+ */
12849
+ get onInsert() {
12850
+ return this.#onInsert
12851
+ }
12852
+ /**
12853
+ * {@link LRUCache.OptionsBase.disposeAfter} (read-only)
12854
+ */
12855
+ get disposeAfter() {
12856
+ return this.#disposeAfter
12857
+ }
12858
+ constructor(options) {
12859
+ const {
12860
+ max = 0,
12861
+ ttl,
12862
+ ttlResolution = 1,
12863
+ ttlAutopurge,
12864
+ updateAgeOnGet,
12865
+ updateAgeOnHas,
12866
+ allowStale,
12867
+ dispose,
12868
+ onInsert,
12869
+ disposeAfter,
12870
+ noDisposeOnSet,
12871
+ noUpdateTTL,
12872
+ maxSize = 0,
12873
+ maxEntrySize = 0,
12874
+ sizeCalculation,
12875
+ fetchMethod,
12876
+ memoMethod,
12877
+ noDeleteOnFetchRejection,
12878
+ noDeleteOnStaleGet,
12879
+ allowStaleOnFetchRejection,
12880
+ allowStaleOnFetchAbort,
12881
+ ignoreFetchAbort
12882
+ } = options
12883
+ if (max !== 0 && !isPosInt(max)) {
12884
+ throw new TypeError('max option must be a nonnegative integer')
12885
+ }
12886
+ const UintArray = max ? getUintArray(max) : Array
12887
+ if (!UintArray) {
12888
+ throw new Error('invalid max value: ' + max)
12889
+ }
12890
+ this.#max = max
12891
+ this.#maxSize = maxSize
12892
+ this.maxEntrySize = maxEntrySize || this.#maxSize
12893
+ this.sizeCalculation = sizeCalculation
12894
+ if (this.sizeCalculation) {
12895
+ if (!this.#maxSize && !this.maxEntrySize) {
12896
+ throw new TypeError(
12897
+ 'cannot set sizeCalculation without setting maxSize or maxEntrySize'
12898
+ )
12899
+ }
12900
+ if (typeof this.sizeCalculation !== 'function') {
12901
+ throw new TypeError('sizeCalculation set to non-function')
12902
+ }
12903
+ }
12904
+ if (memoMethod !== undefined && typeof memoMethod !== 'function') {
12905
+ throw new TypeError('memoMethod must be a function if defined')
12906
+ }
12907
+ this.#memoMethod = memoMethod
12908
+ if (fetchMethod !== undefined && typeof fetchMethod !== 'function') {
12909
+ throw new TypeError('fetchMethod must be a function if specified')
12910
+ }
12911
+ this.#fetchMethod = fetchMethod
12912
+ this.#hasFetchMethod = !!fetchMethod
12913
+ this.#keyMap = new Map()
12914
+ this.#keyList = new Array(max).fill(undefined)
12915
+ this.#valList = new Array(max).fill(undefined)
12916
+ this.#next = new UintArray(max)
12917
+ this.#prev = new UintArray(max)
12918
+ this.#head = 0
12919
+ this.#tail = 0
12920
+ this.#free = Stack.create(max)
12921
+ this.#size = 0
12922
+ this.#calculatedSize = 0
12923
+ if (typeof dispose === 'function') {
12924
+ this.#dispose = dispose
12925
+ }
12926
+ if (typeof onInsert === 'function') {
12927
+ this.#onInsert = onInsert
12928
+ }
12929
+ if (typeof disposeAfter === 'function') {
12930
+ this.#disposeAfter = disposeAfter
12931
+ this.#disposed = []
12932
+ } else {
12933
+ this.#disposeAfter = undefined
12934
+ this.#disposed = undefined
12935
+ }
12936
+ this.#hasDispose = !!this.#dispose
12937
+ this.#hasOnInsert = !!this.#onInsert
12938
+ this.#hasDisposeAfter = !!this.#disposeAfter
12939
+ this.noDisposeOnSet = !!noDisposeOnSet
12940
+ this.noUpdateTTL = !!noUpdateTTL
12941
+ this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection
12942
+ this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection
12943
+ this.allowStaleOnFetchAbort = !!allowStaleOnFetchAbort
12944
+ this.ignoreFetchAbort = !!ignoreFetchAbort
12945
+ // NB: maxEntrySize is set to maxSize if it's set
12946
+ if (this.maxEntrySize !== 0) {
12947
+ if (this.#maxSize !== 0) {
12948
+ if (!isPosInt(this.#maxSize)) {
12949
+ throw new TypeError(
12950
+ 'maxSize must be a positive integer if specified'
12951
+ )
12952
+ }
12953
+ }
12954
+ if (!isPosInt(this.maxEntrySize)) {
12955
+ throw new TypeError(
12956
+ 'maxEntrySize must be a positive integer if specified'
12957
+ )
12958
+ }
12959
+ this.#initializeSizeTracking()
12960
+ }
12961
+ this.allowStale = !!allowStale
12962
+ this.noDeleteOnStaleGet = !!noDeleteOnStaleGet
12963
+ this.updateAgeOnGet = !!updateAgeOnGet
12964
+ this.updateAgeOnHas = !!updateAgeOnHas
12965
+ this.ttlResolution =
12966
+ isPosInt(ttlResolution) || ttlResolution === 0 ? ttlResolution : 1
12967
+ this.ttlAutopurge = !!ttlAutopurge
12968
+ this.ttl = ttl || 0
12969
+ if (this.ttl) {
12970
+ if (!isPosInt(this.ttl)) {
12971
+ throw new TypeError('ttl must be a positive integer if specified')
12972
+ }
12973
+ this.#initializeTTLTracking()
12974
+ }
12975
+ // do not allow completely unbounded caches
12976
+ if (this.#max === 0 && this.ttl === 0 && this.#maxSize === 0) {
12977
+ throw new TypeError('At least one of max, maxSize, or ttl is required')
12978
+ }
12979
+ if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
12980
+ const code = 'LRU_CACHE_UNBOUNDED'
12981
+ if (shouldWarn(code)) {
12982
+ warned.add(code)
12983
+ const msg =
12984
+ 'TTL caching without ttlAutopurge, max, or maxSize can ' +
12985
+ 'result in unbounded memory consumption.'
12986
+ emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache)
12987
+ }
12988
+ }
12989
+ }
12990
+ /**
12991
+ * Return the number of ms left in the item's TTL. If item is not in cache,
12992
+ * returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
12993
+ */
12994
+ getRemainingTTL(key) {
12995
+ return this.#keyMap.has(key) ? Infinity : 0
12996
+ }
12997
+ #initializeTTLTracking() {
12998
+ const ttls = new ZeroArray(this.#max)
12999
+ const starts = new ZeroArray(this.#max)
13000
+ this.#ttls = ttls
13001
+ this.#starts = starts
13002
+ this.#setItemTTL = (index, ttl, start = perf.now()) => {
13003
+ starts[index] = ttl !== 0 ? start : 0
13004
+ ttls[index] = ttl
13005
+ if (ttl !== 0 && this.ttlAutopurge) {
13006
+ const t = setTimeout(() => {
13007
+ if (this.#isStale(index)) {
13008
+ this.#delete(this.#keyList[index], 'expire')
13009
+ }
13010
+ }, ttl + 1)
13011
+ // unref() not supported on all platforms
13012
+ /* c8 ignore start */
13013
+ if (t.unref) {
13014
+ t.unref()
13015
+ }
13016
+ /* c8 ignore stop */
13017
+ }
13018
+ }
13019
+ this.#updateItemAge = index => {
13020
+ starts[index] = ttls[index] !== 0 ? perf.now() : 0
13021
+ }
13022
+ this.#statusTTL = (status, index) => {
13023
+ if (ttls[index]) {
13024
+ const ttl = ttls[index]
13025
+ const start = starts[index]
13026
+ /* c8 ignore next */
13027
+ if (!ttl || !start) {
13028
+ return
13029
+ }
13030
+ status.ttl = ttl
13031
+ status.start = start
13032
+ status.now = cachedNow || getNow()
13033
+ const age = status.now - start
13034
+ status.remainingTTL = ttl - age
13035
+ }
13036
+ }
13037
+ // debounce calls to perf.now() to 1s so we're not hitting
13038
+ // that costly call repeatedly.
13039
+ let cachedNow = 0
13040
+ const getNow = () => {
13041
+ const n = perf.now()
13042
+ if (this.ttlResolution > 0) {
13043
+ cachedNow = n
13044
+ const t = setTimeout(() => (cachedNow = 0), this.ttlResolution)
13045
+ // not available on all platforms
13046
+ /* c8 ignore start */
13047
+ if (t.unref) {
13048
+ t.unref()
13049
+ }
13050
+ /* c8 ignore stop */
13051
+ }
13052
+ return n
13053
+ }
13054
+ this.getRemainingTTL = key => {
13055
+ const index = this.#keyMap.get(key)
13056
+ if (index === undefined) {
13057
+ return 0
13058
+ }
13059
+ const ttl = ttls[index]
13060
+ const start = starts[index]
13061
+ if (!ttl || !start) {
13062
+ return Infinity
13063
+ }
13064
+ const age = (cachedNow || getNow()) - start
13065
+ return ttl - age
13066
+ }
13067
+ this.#isStale = index => {
13068
+ const s = starts[index]
13069
+ const t = ttls[index]
13070
+ return !!t && !!s && (cachedNow || getNow()) - s > t
13071
+ }
13072
+ }
13073
+ // conditionally set private methods related to TTL
13074
+ #updateItemAge = () => {}
13075
+ #statusTTL = () => {}
13076
+ #setItemTTL = () => {}
13077
+ /* c8 ignore stop */
13078
+ #isStale = () => false
13079
+ #initializeSizeTracking() {
13080
+ const sizes = new ZeroArray(this.#max)
13081
+ this.#calculatedSize = 0
13082
+ this.#sizes = sizes
13083
+ this.#removeItemSize = index => {
13084
+ this.#calculatedSize -= sizes[index]
13085
+ sizes[index] = 0
13086
+ }
13087
+ this.#requireSize = (k, v, size, sizeCalculation) => {
13088
+ // provisionally accept background fetches.
13089
+ // actual value size will be checked when they return.
13090
+ if (this.#isBackgroundFetch(v)) {
13091
+ return 0
13092
+ }
13093
+ if (!isPosInt(size)) {
13094
+ if (sizeCalculation) {
13095
+ if (typeof sizeCalculation !== 'function') {
13096
+ throw new TypeError('sizeCalculation must be a function')
13097
+ }
13098
+ size = sizeCalculation(v, k)
13099
+ if (!isPosInt(size)) {
13100
+ throw new TypeError(
13101
+ 'sizeCalculation return invalid (expect positive integer)'
13102
+ )
13103
+ }
13104
+ } else {
13105
+ throw new TypeError(
13106
+ 'invalid size value (must be positive integer). ' +
13107
+ 'When maxSize or maxEntrySize is used, sizeCalculation ' +
13108
+ 'or size must be set.'
13109
+ )
13110
+ }
13111
+ }
13112
+ return size
13113
+ }
13114
+ this.#addItemSize = (index, size, status) => {
13115
+ sizes[index] = size
13116
+ if (this.#maxSize) {
13117
+ const maxSize = this.#maxSize - sizes[index]
13118
+ while (this.#calculatedSize > maxSize) {
13119
+ this.#evict(true)
13120
+ }
13121
+ }
13122
+ this.#calculatedSize += sizes[index]
13123
+ if (status) {
13124
+ status.entrySize = size
13125
+ status.totalCalculatedSize = this.#calculatedSize
13126
+ }
13127
+ }
13128
+ }
13129
+ #removeItemSize = _i => {}
13130
+ #addItemSize = (_i, _s, _st) => {}
13131
+ #requireSize = (_k, _v, size, sizeCalculation) => {
13132
+ if (size || sizeCalculation) {
13133
+ throw new TypeError(
13134
+ 'cannot set size without setting maxSize or maxEntrySize on cache'
13135
+ )
13136
+ }
13137
+ return 0
13138
+ };
13139
+ *#indexes({ allowStale = this.allowStale } = {}) {
13140
+ if (this.#size) {
13141
+ for (let i = this.#tail; true; ) {
13142
+ if (!this.#isValidIndex(i)) {
13143
+ break
13144
+ }
13145
+ if (allowStale || !this.#isStale(i)) {
13146
+ yield i
13147
+ }
13148
+ if (i === this.#head) {
13149
+ break
13150
+ } else {
13151
+ i = this.#prev[i]
13152
+ }
13153
+ }
13154
+ }
13155
+ }
13156
+ *#rindexes({ allowStale = this.allowStale } = {}) {
13157
+ if (this.#size) {
13158
+ for (let i = this.#head; true; ) {
13159
+ if (!this.#isValidIndex(i)) {
13160
+ break
13161
+ }
13162
+ if (allowStale || !this.#isStale(i)) {
13163
+ yield i
13164
+ }
13165
+ if (i === this.#tail) {
13166
+ break
13167
+ } else {
13168
+ i = this.#next[i]
13169
+ }
13170
+ }
13171
+ }
13172
+ }
13173
+ #isValidIndex(index) {
13174
+ return (
13175
+ index !== undefined && this.#keyMap.get(this.#keyList[index]) === index
13176
+ )
13177
+ }
13178
+ /**
13179
+ * Return a generator yielding `[key, value]` pairs,
13180
+ * in order from most recently used to least recently used.
13181
+ */
13182
+ *entries() {
13183
+ for (const i of this.#indexes()) {
13184
+ if (
13185
+ this.#valList[i] !== undefined &&
13186
+ this.#keyList[i] !== undefined &&
13187
+ !this.#isBackgroundFetch(this.#valList[i])
13188
+ ) {
13189
+ yield [this.#keyList[i], this.#valList[i]]
13190
+ }
13191
+ }
13192
+ }
13193
+ /**
13194
+ * Inverse order version of {@link LRUCache.entries}
13195
+ *
13196
+ * Return a generator yielding `[key, value]` pairs,
13197
+ * in order from least recently used to most recently used.
13198
+ */
13199
+ *rentries() {
13200
+ for (const i of this.#rindexes()) {
13201
+ if (
13202
+ this.#valList[i] !== undefined &&
13203
+ this.#keyList[i] !== undefined &&
13204
+ !this.#isBackgroundFetch(this.#valList[i])
13205
+ ) {
13206
+ yield [this.#keyList[i], this.#valList[i]]
13207
+ }
13208
+ }
13209
+ }
13210
+ /**
13211
+ * Return a generator yielding the keys in the cache,
13212
+ * in order from most recently used to least recently used.
13213
+ */
13214
+ *keys() {
13215
+ for (const i of this.#indexes()) {
13216
+ const k = this.#keyList[i]
13217
+ if (k !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
13218
+ yield k
13219
+ }
13220
+ }
13221
+ }
13222
+ /**
13223
+ * Inverse order version of {@link LRUCache.keys}
13224
+ *
13225
+ * Return a generator yielding the keys in the cache,
13226
+ * in order from least recently used to most recently used.
13227
+ */
13228
+ *rkeys() {
13229
+ for (const i of this.#rindexes()) {
13230
+ const k = this.#keyList[i]
13231
+ if (k !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
13232
+ yield k
13233
+ }
13234
+ }
13235
+ }
13236
+ /**
13237
+ * Return a generator yielding the values in the cache,
13238
+ * in order from most recently used to least recently used.
13239
+ */
13240
+ *values() {
13241
+ for (const i of this.#indexes()) {
13242
+ const v = this.#valList[i]
13243
+ if (v !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
13244
+ yield this.#valList[i]
13245
+ }
13246
+ }
13247
+ }
13248
+ /**
13249
+ * Inverse order version of {@link LRUCache.values}
13250
+ *
13251
+ * Return a generator yielding the values in the cache,
13252
+ * in order from least recently used to most recently used.
13253
+ */
13254
+ *rvalues() {
13255
+ for (const i of this.#rindexes()) {
13256
+ const v = this.#valList[i]
13257
+ if (v !== undefined && !this.#isBackgroundFetch(this.#valList[i])) {
13258
+ yield this.#valList[i]
13259
+ }
13260
+ }
13261
+ }
13262
+ /**
13263
+ * Iterating over the cache itself yields the same results as
13264
+ * {@link LRUCache.entries}
13265
+ */
13266
+ [Symbol.iterator]() {
13267
+ return this.entries()
13268
+ }
13269
+ /**
13270
+ * A String value that is used in the creation of the default string
13271
+ * description of an object. Called by the built-in method
13272
+ * `Object.prototype.toString`.
13273
+ */
13274
+ [Symbol.toStringTag] = 'LRUCache'
13275
+ /**
13276
+ * Find a value for which the supplied fn method returns a truthy value,
13277
+ * similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
13278
+ */
13279
+ find(fn, getOptions = {}) {
13280
+ for (const i of this.#indexes()) {
13281
+ const v = this.#valList[i]
13282
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v
13283
+ if (value === undefined) {
13284
+ continue
13285
+ }
13286
+ if (fn(value, this.#keyList[i], this)) {
13287
+ return this.get(this.#keyList[i], getOptions)
13288
+ }
13289
+ }
13290
+ }
13291
+ /**
13292
+ * Call the supplied function on each item in the cache, in order from most
13293
+ * recently used to least recently used.
13294
+ *
13295
+ * `fn` is called as `fn(value, key, cache)`.
13296
+ *
13297
+ * If `thisp` is provided, function will be called in the `this`-context of
13298
+ * the provided object, or the cache if no `thisp` object is provided.
13299
+ *
13300
+ * Does not update age or recenty of use, or iterate over stale values.
13301
+ */
13302
+ forEach(fn, thisp = this) {
13303
+ for (const i of this.#indexes()) {
13304
+ const v = this.#valList[i]
13305
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v
13306
+ if (value === undefined) {
13307
+ continue
13308
+ }
13309
+ fn.call(thisp, value, this.#keyList[i], this)
13310
+ }
13311
+ }
13312
+ /**
13313
+ * The same as {@link LRUCache.forEach} but items are iterated over in
13314
+ * reverse order. (ie, less recently used items are iterated over first.)
13315
+ */
13316
+ rforEach(fn, thisp = this) {
13317
+ for (const i of this.#rindexes()) {
13318
+ const v = this.#valList[i]
13319
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v
13320
+ if (value === undefined) {
13321
+ continue
13322
+ }
13323
+ fn.call(thisp, value, this.#keyList[i], this)
13324
+ }
13325
+ }
13326
+ /**
13327
+ * Delete any stale entries. Returns true if anything was removed,
13328
+ * false otherwise.
13329
+ */
13330
+ purgeStale() {
13331
+ let deleted = false
13332
+ for (const i of this.#rindexes({
13333
+ allowStale: true
13334
+ })) {
13335
+ if (this.#isStale(i)) {
13336
+ this.#delete(this.#keyList[i], 'expire')
13337
+ deleted = true
13338
+ }
13339
+ }
13340
+ return deleted
13341
+ }
13342
+ /**
13343
+ * Get the extended info about a given entry, to get its value, size, and
13344
+ * TTL info simultaneously. Returns `undefined` if the key is not present.
13345
+ *
13346
+ * Unlike {@link LRUCache#dump}, which is designed to be portable and survive
13347
+ * serialization, the `start` value is always the current timestamp, and the
13348
+ * `ttl` is a calculated remaining time to live (negative if expired).
13349
+ *
13350
+ * Always returns stale values, if their info is found in the cache, so be
13351
+ * sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
13352
+ * if relevant.
13353
+ */
13354
+ info(key) {
13355
+ const i = this.#keyMap.get(key)
13356
+ if (i === undefined) {
13357
+ return undefined
13358
+ }
13359
+ const v = this.#valList[i]
13360
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v
13361
+ if (value === undefined) {
13362
+ return undefined
13363
+ }
13364
+ const entry = {
13365
+ value
13366
+ }
13367
+ if (this.#ttls && this.#starts) {
13368
+ const ttl = this.#ttls[i]
13369
+ const start = this.#starts[i]
13370
+ if (ttl && start) {
13371
+ const remain = ttl - (perf.now() - start)
13372
+ entry.ttl = remain
13373
+ entry.start = Date.now()
13374
+ }
13375
+ }
13376
+ if (this.#sizes) {
13377
+ entry.size = this.#sizes[i]
13378
+ }
13379
+ return entry
13380
+ }
13381
+ /**
13382
+ * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
13383
+ * passed to {@link LRUCache#load}.
13384
+ *
13385
+ * The `start` fields are calculated relative to a portable `Date.now()`
13386
+ * timestamp, even if `performance.now()` is available.
13387
+ *
13388
+ * Stale entries are always included in the `dump`, even if
13389
+ * {@link LRUCache.OptionsBase.allowStale} is false.
13390
+ *
13391
+ * Note: this returns an actual array, not a generator, so it can be more
13392
+ * easily passed around.
13393
+ */
13394
+ dump() {
13395
+ const arr = []
13396
+ for (const i of this.#indexes({
13397
+ allowStale: true
13398
+ })) {
13399
+ const key = this.#keyList[i]
13400
+ const v = this.#valList[i]
13401
+ const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v
13402
+ if (value === undefined || key === undefined) {
13403
+ continue
13404
+ }
13405
+ const entry = {
13406
+ value
13407
+ }
13408
+ if (this.#ttls && this.#starts) {
13409
+ entry.ttl = this.#ttls[i]
13410
+ // always dump the start relative to a portable timestamp
13411
+ // it's ok for this to be a bit slow, it's a rare operation.
13412
+ const age = perf.now() - this.#starts[i]
13413
+ entry.start = Math.floor(Date.now() - age)
13414
+ }
13415
+ if (this.#sizes) {
13416
+ entry.size = this.#sizes[i]
13417
+ }
13418
+ arr.unshift([key, entry])
13419
+ }
13420
+ return arr
13421
+ }
13422
+ /**
13423
+ * Reset the cache and load in the items in entries in the order listed.
13424
+ *
13425
+ * The shape of the resulting cache may be different if the same options are
13426
+ * not used in both caches.
13427
+ *
13428
+ * The `start` fields are assumed to be calculated relative to a portable
13429
+ * `Date.now()` timestamp, even if `performance.now()` is available.
13430
+ */
13431
+ load(arr) {
13432
+ this.clear()
13433
+ for (const [key, entry] of arr) {
13434
+ if (entry.start) {
13435
+ // entry.start is a portable timestamp, but we may be using
13436
+ // node's performance.now(), so calculate the offset, so that
13437
+ // we get the intended remaining TTL, no matter how long it's
13438
+ // been on ice.
13439
+ //
13440
+ // it's ok for this to be a bit slow, it's a rare operation.
13441
+ const age = Date.now() - entry.start
13442
+ entry.start = perf.now() - age
13443
+ }
13444
+ this.set(key, entry.value, entry)
13445
+ }
13446
+ }
13447
+ /**
13448
+ * Add a value to the cache.
13449
+ *
13450
+ * Note: if `undefined` is specified as a value, this is an alias for
13451
+ * {@link LRUCache#delete}
13452
+ *
13453
+ * Fields on the {@link LRUCache.SetOptions} options param will override
13454
+ * their corresponding values in the constructor options for the scope
13455
+ * of this single `set()` operation.
13456
+ *
13457
+ * If `start` is provided, then that will set the effective start
13458
+ * time for the TTL calculation. Note that this must be a previous
13459
+ * value of `performance.now()` if supported, or a previous value of
13460
+ * `Date.now()` if not.
13461
+ *
13462
+ * Options object may also include `size`, which will prevent
13463
+ * calling the `sizeCalculation` function and just use the specified
13464
+ * number if it is a positive integer, and `noDisposeOnSet` which
13465
+ * will prevent calling a `dispose` function in the case of
13466
+ * overwrites.
13467
+ *
13468
+ * If the `size` (or return value of `sizeCalculation`) for a given
13469
+ * entry is greater than `maxEntrySize`, then the item will not be
13470
+ * added to the cache.
13471
+ *
13472
+ * Will update the recency of the entry.
13473
+ *
13474
+ * If the value is `undefined`, then this is an alias for
13475
+ * `cache.delete(key)`. `undefined` is never stored in the cache.
13476
+ */
13477
+ set(k, v, setOptions = {}) {
13478
+ if (v === undefined) {
13479
+ this.delete(k)
13480
+ return this
13481
+ }
13482
+ const {
13483
+ ttl = this.ttl,
13484
+ start,
13485
+ noDisposeOnSet = this.noDisposeOnSet,
13486
+ sizeCalculation = this.sizeCalculation,
13487
+ status
13488
+ } = setOptions
13489
+ let { noUpdateTTL = this.noUpdateTTL } = setOptions
13490
+ const size = this.#requireSize(
13491
+ k,
13492
+ v,
13493
+ setOptions.size || 0,
13494
+ sizeCalculation
13495
+ )
13496
+ // if the item doesn't fit, don't do anything
13497
+ // NB: maxEntrySize set to maxSize by default
13498
+ if (this.maxEntrySize && size > this.maxEntrySize) {
13499
+ if (status) {
13500
+ status.set = 'miss'
13501
+ status.maxEntrySizeExceeded = true
13502
+ }
13503
+ // have to delete, in case something is there already.
13504
+ this.#delete(k, 'set')
13505
+ return this
13506
+ }
13507
+ let index = this.#size === 0 ? undefined : this.#keyMap.get(k)
13508
+ if (index === undefined) {
13509
+ // addition
13510
+ index =
13511
+ this.#size === 0
13512
+ ? this.#tail
13513
+ : this.#free.length !== 0
13514
+ ? this.#free.pop()
13515
+ : this.#size === this.#max
13516
+ ? this.#evict(false)
13517
+ : this.#size
13518
+ this.#keyList[index] = k
13519
+ this.#valList[index] = v
13520
+ this.#keyMap.set(k, index)
13521
+ this.#next[this.#tail] = index
13522
+ this.#prev[index] = this.#tail
13523
+ this.#tail = index
13524
+ this.#size++
13525
+ this.#addItemSize(index, size, status)
13526
+ if (status) {
13527
+ status.set = 'add'
13528
+ }
13529
+ noUpdateTTL = false
13530
+ if (this.#hasOnInsert) {
13531
+ this.#onInsert?.(v, k, 'add')
13532
+ }
13533
+ } else {
13534
+ // update
13535
+ this.#moveToTail(index)
13536
+ const oldVal = this.#valList[index]
13537
+ if (v !== oldVal) {
13538
+ if (this.#hasFetchMethod && this.#isBackgroundFetch(oldVal)) {
13539
+ oldVal.__abortController.abort(new Error('replaced'))
13540
+ const { __staleWhileFetching: s } = oldVal
13541
+ if (s !== undefined && !noDisposeOnSet) {
13542
+ if (this.#hasDispose) {
13543
+ this.#dispose?.(s, k, 'set')
13544
+ }
13545
+ if (this.#hasDisposeAfter) {
13546
+ this.#disposed?.push([s, k, 'set'])
13547
+ }
13548
+ }
13549
+ } else if (!noDisposeOnSet) {
13550
+ if (this.#hasDispose) {
13551
+ this.#dispose?.(oldVal, k, 'set')
13552
+ }
13553
+ if (this.#hasDisposeAfter) {
13554
+ this.#disposed?.push([oldVal, k, 'set'])
13555
+ }
13556
+ }
13557
+ this.#removeItemSize(index)
13558
+ this.#addItemSize(index, size, status)
13559
+ this.#valList[index] = v
13560
+ if (status) {
13561
+ status.set = 'replace'
13562
+ const oldValue =
13563
+ oldVal && this.#isBackgroundFetch(oldVal)
13564
+ ? oldVal.__staleWhileFetching
13565
+ : oldVal
13566
+ if (oldValue !== undefined) {
13567
+ status.oldValue = oldValue
13568
+ }
13569
+ }
13570
+ } else if (status) {
13571
+ status.set = 'update'
13572
+ }
13573
+ if (this.#hasOnInsert) {
13574
+ this.onInsert?.(v, k, v === oldVal ? 'update' : 'replace')
13575
+ }
13576
+ }
13577
+ if (ttl !== 0 && !this.#ttls) {
13578
+ this.#initializeTTLTracking()
13579
+ }
13580
+ if (this.#ttls) {
13581
+ if (!noUpdateTTL) {
13582
+ this.#setItemTTL(index, ttl, start)
13583
+ }
13584
+ if (status) {
13585
+ this.#statusTTL(status, index)
13586
+ }
13587
+ }
13588
+ if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
13589
+ const dt = this.#disposed
13590
+ let task
13591
+ while ((task = dt?.shift())) {
13592
+ this.#disposeAfter?.(...task)
13593
+ }
13594
+ }
13595
+ return this
13596
+ }
13597
+ /**
13598
+ * Evict the least recently used item, returning its value or
13599
+ * `undefined` if cache is empty.
13600
+ */
13601
+ pop() {
13602
+ try {
13603
+ while (this.#size) {
13604
+ const val = this.#valList[this.#head]
13605
+ this.#evict(true)
13606
+ if (this.#isBackgroundFetch(val)) {
13607
+ if (val.__staleWhileFetching) {
13608
+ return val.__staleWhileFetching
13609
+ }
13610
+ } else if (val !== undefined) {
13611
+ return val
13612
+ }
13613
+ }
13614
+ } finally {
13615
+ if (this.#hasDisposeAfter && this.#disposed) {
13616
+ const dt = this.#disposed
13617
+ let task
13618
+ while ((task = dt?.shift())) {
13619
+ this.#disposeAfter?.(...task)
13620
+ }
13621
+ }
13622
+ }
13623
+ }
13624
+ #evict(free) {
13625
+ const head = this.#head
13626
+ const k = this.#keyList[head]
13627
+ const v = this.#valList[head]
13628
+ if (this.#hasFetchMethod && this.#isBackgroundFetch(v)) {
13629
+ v.__abortController.abort(new Error('evicted'))
13630
+ } else if (this.#hasDispose || this.#hasDisposeAfter) {
13631
+ if (this.#hasDispose) {
13632
+ this.#dispose?.(v, k, 'evict')
13633
+ }
13634
+ if (this.#hasDisposeAfter) {
13635
+ this.#disposed?.push([v, k, 'evict'])
13636
+ }
13637
+ }
13638
+ this.#removeItemSize(head)
13639
+ // if we aren't about to use the index, then null these out
13640
+ if (free) {
13641
+ this.#keyList[head] = undefined
13642
+ this.#valList[head] = undefined
13643
+ this.#free.push(head)
13644
+ }
13645
+ if (this.#size === 1) {
13646
+ this.#head = this.#tail = 0
13647
+ this.#free.length = 0
13648
+ } else {
13649
+ this.#head = this.#next[head]
13650
+ }
13651
+ this.#keyMap.delete(k)
13652
+ this.#size--
13653
+ return head
13654
+ }
13655
+ /**
13656
+ * Check if a key is in the cache, without updating the recency of use.
13657
+ * Will return false if the item is stale, even though it is technically
13658
+ * in the cache.
13659
+ *
13660
+ * Check if a key is in the cache, without updating the recency of
13661
+ * use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
13662
+ * to `true` in either the options or the constructor.
13663
+ *
13664
+ * Will return `false` if the item is stale, even though it is technically in
13665
+ * the cache. The difference can be determined (if it matters) by using a
13666
+ * `status` argument, and inspecting the `has` field.
13667
+ *
13668
+ * Will not update item age unless
13669
+ * {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
13670
+ */
13671
+ has(k, hasOptions = {}) {
13672
+ const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions
13673
+ const index = this.#keyMap.get(k)
13674
+ if (index !== undefined) {
13675
+ const v = this.#valList[index]
13676
+ if (
13677
+ this.#isBackgroundFetch(v) &&
13678
+ v.__staleWhileFetching === undefined
13679
+ ) {
13680
+ return false
13681
+ }
13682
+ if (!this.#isStale(index)) {
13683
+ if (updateAgeOnHas) {
13684
+ this.#updateItemAge(index)
13685
+ }
13686
+ if (status) {
13687
+ status.has = 'hit'
13688
+ this.#statusTTL(status, index)
13689
+ }
13690
+ return true
13691
+ } else if (status) {
13692
+ status.has = 'stale'
13693
+ this.#statusTTL(status, index)
13694
+ }
13695
+ } else if (status) {
13696
+ status.has = 'miss'
13697
+ }
13698
+ return false
13699
+ }
13700
+ /**
13701
+ * Like {@link LRUCache#get} but doesn't update recency or delete stale
13702
+ * items.
13703
+ *
13704
+ * Returns `undefined` if the item is stale, unless
13705
+ * {@link LRUCache.OptionsBase.allowStale} is set.
13706
+ */
13707
+ peek(k, peekOptions = {}) {
13708
+ const { allowStale = this.allowStale } = peekOptions
13709
+ const index = this.#keyMap.get(k)
13710
+ if (index === undefined || (!allowStale && this.#isStale(index))) {
13711
+ return
13712
+ }
13713
+ const v = this.#valList[index]
13714
+ // either stale and allowed, or forcing a refresh of non-stale value
13715
+ return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v
13716
+ }
13717
+ #backgroundFetch(k, index, options, context) {
13718
+ const v = index === undefined ? undefined : this.#valList[index]
13719
+ if (this.#isBackgroundFetch(v)) {
13720
+ return v
13721
+ }
13722
+ const ac = new AC()
13723
+ const { signal } = options
13724
+ // when/if our AC signals, then stop listening to theirs.
13725
+ signal?.addEventListener('abort', () => ac.abort(signal.reason), {
13726
+ signal: ac.signal
13727
+ })
13728
+ const fetchOpts = {
13729
+ signal: ac.signal,
13730
+ options,
13731
+ context
13732
+ }
13733
+ const cb = (v, updateCache = false) => {
13734
+ const { aborted } = ac.signal
13735
+ const ignoreAbort = options.ignoreFetchAbort && v !== undefined
13736
+ if (options.status) {
13737
+ if (aborted && !updateCache) {
13738
+ options.status.fetchAborted = true
13739
+ options.status.fetchError = ac.signal.reason
13740
+ if (ignoreAbort) {
13741
+ options.status.fetchAbortIgnored = true
13742
+ }
13743
+ } else {
13744
+ options.status.fetchResolved = true
13745
+ }
13746
+ }
13747
+ if (aborted && !ignoreAbort && !updateCache) {
13748
+ return fetchFail(ac.signal.reason)
13749
+ }
13750
+ // either we didn't abort, and are still here, or we did, and ignored
13751
+ const bf = p
13752
+ if (this.#valList[index] === p) {
13753
+ if (v === undefined) {
13754
+ if (bf.__staleWhileFetching) {
13755
+ this.#valList[index] = bf.__staleWhileFetching
13756
+ } else {
13757
+ this.#delete(k, 'fetch')
13758
+ }
13759
+ } else {
13760
+ if (options.status) {
13761
+ options.status.fetchUpdated = true
13762
+ }
13763
+ this.set(k, v, fetchOpts.options)
13764
+ }
13765
+ }
13766
+ return v
13767
+ }
13768
+ const eb = er => {
13769
+ if (options.status) {
13770
+ options.status.fetchRejected = true
13771
+ options.status.fetchError = er
13772
+ }
13773
+ return fetchFail(er)
13774
+ }
13775
+ const fetchFail = er => {
13776
+ const { aborted } = ac.signal
13777
+ const allowStaleAborted = aborted && options.allowStaleOnFetchAbort
13778
+ const allowStale =
13779
+ allowStaleAborted || options.allowStaleOnFetchRejection
13780
+ const noDelete = allowStale || options.noDeleteOnFetchRejection
13781
+ const bf = p
13782
+ if (this.#valList[index] === p) {
13783
+ // if we allow stale on fetch rejections, then we need to ensure that
13784
+ // the stale value is not removed from the cache when the fetch fails.
13785
+ const del = !noDelete || bf.__staleWhileFetching === undefined
13786
+ if (del) {
13787
+ this.#delete(k, 'fetch')
13788
+ } else if (!allowStaleAborted) {
13789
+ // still replace the *promise* with the stale value,
13790
+ // since we are done with the promise at this point.
13791
+ // leave it untouched if we're still waiting for an
13792
+ // aborted background fetch that hasn't yet returned.
13793
+ this.#valList[index] = bf.__staleWhileFetching
13794
+ }
13795
+ }
13796
+ if (allowStale) {
13797
+ if (options.status && bf.__staleWhileFetching !== undefined) {
13798
+ options.status.returnedStale = true
13799
+ }
13800
+ return bf.__staleWhileFetching
13801
+ } else if (bf.__returned === bf) {
13802
+ throw er
13803
+ }
13804
+ }
13805
+ const pcall = (res, rej) => {
13806
+ const fmp = this.#fetchMethod?.(k, v, fetchOpts)
13807
+ if (fmp && fmp instanceof Promise) {
13808
+ fmp.then(v => res(v === undefined ? undefined : v), rej)
13809
+ }
13810
+ // ignored, we go until we finish, regardless.
13811
+ // defer check until we are actually aborting,
13812
+ // so fetchMethod can override.
13813
+ ac.signal.addEventListener('abort', () => {
13814
+ if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
13815
+ res(undefined)
13816
+ // when it eventually resolves, update the cache.
13817
+ if (options.allowStaleOnFetchAbort) {
13818
+ res = v => cb(v, true)
13819
+ }
13820
+ }
13821
+ })
13822
+ }
13823
+ if (options.status) {
13824
+ options.status.fetchDispatched = true
13825
+ }
13826
+ const p = new Promise(pcall).then(cb, eb)
13827
+ const bf = Object.assign(p, {
13828
+ __abortController: ac,
13829
+ __staleWhileFetching: v,
13830
+ __returned: undefined
13831
+ })
13832
+ if (index === undefined) {
13833
+ // internal, don't expose status.
13834
+ this.set(k, bf, {
13835
+ ...fetchOpts.options,
13836
+ status: undefined
13837
+ })
13838
+ index = this.#keyMap.get(k)
13839
+ } else {
13840
+ this.#valList[index] = bf
13841
+ }
13842
+ return bf
13843
+ }
13844
+ #isBackgroundFetch(p) {
13845
+ if (!this.#hasFetchMethod) {
13846
+ return false
13847
+ }
13848
+ const b = p
13849
+ return (
13850
+ !!b &&
13851
+ b instanceof Promise &&
13852
+ b.hasOwnProperty('__staleWhileFetching') &&
13853
+ b.__abortController instanceof AC
13854
+ )
13855
+ }
13856
+ async fetch(k, fetchOptions = {}) {
13857
+ const {
13858
+ // get options
13859
+ allowStale = this.allowStale,
13860
+ updateAgeOnGet = this.updateAgeOnGet,
13861
+ noDeleteOnStaleGet = this.noDeleteOnStaleGet,
13862
+ // set options
13863
+ ttl = this.ttl,
13864
+ noDisposeOnSet = this.noDisposeOnSet,
13865
+ size = 0,
13866
+ sizeCalculation = this.sizeCalculation,
13867
+ noUpdateTTL = this.noUpdateTTL,
13868
+ // fetch exclusive options
13869
+ noDeleteOnFetchRejection = this.noDeleteOnFetchRejection,
13870
+ allowStaleOnFetchRejection = this.allowStaleOnFetchRejection,
13871
+ ignoreFetchAbort = this.ignoreFetchAbort,
13872
+ allowStaleOnFetchAbort = this.allowStaleOnFetchAbort,
13873
+ context,
13874
+ forceRefresh = false,
13875
+ status,
13876
+ signal
13877
+ } = fetchOptions
13878
+ if (!this.#hasFetchMethod) {
13879
+ if (status) {
13880
+ status.fetch = 'get'
13881
+ }
13882
+ return this.get(k, {
13883
+ allowStale,
13884
+ updateAgeOnGet,
13885
+ noDeleteOnStaleGet,
13886
+ status
13887
+ })
13888
+ }
13889
+ const options = {
13890
+ allowStale,
13891
+ updateAgeOnGet,
13892
+ noDeleteOnStaleGet,
13893
+ ttl,
13894
+ noDisposeOnSet,
13895
+ size,
13896
+ sizeCalculation,
13897
+ noUpdateTTL,
13898
+ noDeleteOnFetchRejection,
13899
+ allowStaleOnFetchRejection,
13900
+ allowStaleOnFetchAbort,
13901
+ ignoreFetchAbort,
13902
+ status,
13903
+ signal
13904
+ }
13905
+ let index = this.#keyMap.get(k)
13906
+ if (index === undefined) {
13907
+ if (status) {
13908
+ status.fetch = 'miss'
13909
+ }
13910
+ const p = this.#backgroundFetch(k, index, options, context)
13911
+ return (p.__returned = p)
13912
+ } else {
13913
+ // in cache, maybe already fetching
13914
+ const v = this.#valList[index]
13915
+ if (this.#isBackgroundFetch(v)) {
13916
+ const stale = allowStale && v.__staleWhileFetching !== undefined
13917
+ if (status) {
13918
+ status.fetch = 'inflight'
13919
+ if (stale) {
13920
+ status.returnedStale = true
13921
+ }
13922
+ }
13923
+ return stale ? v.__staleWhileFetching : (v.__returned = v)
13924
+ }
13925
+ // if we force a refresh, that means do NOT serve the cached value,
13926
+ // unless we are already in the process of refreshing the cache.
13927
+ const isStale = this.#isStale(index)
13928
+ if (!forceRefresh && !isStale) {
13929
+ if (status) {
13930
+ status.fetch = 'hit'
13931
+ }
13932
+ this.#moveToTail(index)
13933
+ if (updateAgeOnGet) {
13934
+ this.#updateItemAge(index)
13935
+ }
13936
+ if (status) {
13937
+ this.#statusTTL(status, index)
13938
+ }
13939
+ return v
13940
+ }
13941
+ // ok, it is stale or a forced refresh, and not already fetching.
13942
+ // refresh the cache.
13943
+ const p = this.#backgroundFetch(k, index, options, context)
13944
+ const hasStale = p.__staleWhileFetching !== undefined
13945
+ const staleVal = hasStale && allowStale
13946
+ if (status) {
13947
+ status.fetch = isStale ? 'stale' : 'refresh'
13948
+ if (staleVal && isStale) {
13949
+ status.returnedStale = true
13950
+ }
13951
+ }
13952
+ return staleVal ? p.__staleWhileFetching : (p.__returned = p)
13953
+ }
13954
+ }
13955
+ async forceFetch(k, fetchOptions = {}) {
13956
+ const v = await this.fetch(k, fetchOptions)
13957
+ if (v === undefined) {
13958
+ throw new Error('fetch() returned undefined')
13959
+ }
13960
+ return v
13961
+ }
13962
+ memo(k, memoOptions = {}) {
13963
+ const memoMethod = this.#memoMethod
13964
+ if (!memoMethod) {
13965
+ throw new Error('no memoMethod provided to constructor')
13966
+ }
13967
+ const { context, forceRefresh, ...options } = memoOptions
13968
+ const v = this.get(k, options)
13969
+ if (!forceRefresh && v !== undefined) {
13970
+ return v
13971
+ }
13972
+ const vv = memoMethod(k, v, {
13973
+ options,
13974
+ context
13975
+ })
13976
+ this.set(k, vv, options)
13977
+ return vv
13978
+ }
13979
+ /**
13980
+ * Return a value from the cache. Will update the recency of the cache
13981
+ * entry found.
13982
+ *
13983
+ * If the key is not found, get() will return `undefined`.
13984
+ */
13985
+ get(k, getOptions = {}) {
13986
+ const {
13987
+ allowStale = this.allowStale,
13988
+ updateAgeOnGet = this.updateAgeOnGet,
13989
+ noDeleteOnStaleGet = this.noDeleteOnStaleGet,
13990
+ status
13991
+ } = getOptions
13992
+ const index = this.#keyMap.get(k)
13993
+ if (index !== undefined) {
13994
+ const value = this.#valList[index]
13995
+ const fetching = this.#isBackgroundFetch(value)
13996
+ if (status) {
13997
+ this.#statusTTL(status, index)
13998
+ }
13999
+ if (this.#isStale(index)) {
14000
+ if (status) {
14001
+ status.get = 'stale'
14002
+ }
14003
+ // delete only if not an in-flight background fetch
14004
+ if (!fetching) {
14005
+ if (!noDeleteOnStaleGet) {
14006
+ this.#delete(k, 'expire')
14007
+ }
14008
+ if (status && allowStale) {
14009
+ status.returnedStale = true
14010
+ }
14011
+ return allowStale ? value : undefined
14012
+ } else {
14013
+ if (
14014
+ status &&
14015
+ allowStale &&
14016
+ value.__staleWhileFetching !== undefined
14017
+ ) {
14018
+ status.returnedStale = true
14019
+ }
14020
+ return allowStale ? value.__staleWhileFetching : undefined
14021
+ }
14022
+ } else {
14023
+ if (status) {
14024
+ status.get = 'hit'
14025
+ }
14026
+ // if we're currently fetching it, we don't actually have it yet
14027
+ // it's not stale, which means this isn't a staleWhileRefetching.
14028
+ // If it's not stale, and fetching, AND has a __staleWhileFetching
14029
+ // value, then that means the user fetched with {forceRefresh:true},
14030
+ // so it's safe to return that value.
14031
+ if (fetching) {
14032
+ return value.__staleWhileFetching
14033
+ }
14034
+ this.#moveToTail(index)
14035
+ if (updateAgeOnGet) {
14036
+ this.#updateItemAge(index)
14037
+ }
14038
+ return value
14039
+ }
14040
+ } else if (status) {
14041
+ status.get = 'miss'
14042
+ }
14043
+ }
14044
+ #connect(p, n) {
14045
+ this.#prev[n] = p
14046
+ this.#next[p] = n
14047
+ }
14048
+ #moveToTail(index) {
14049
+ // if tail already, nothing to do
14050
+ // if head, move head to next[index]
14051
+ // else
14052
+ // move next[prev[index]] to next[index] (head has no prev)
14053
+ // move prev[next[index]] to prev[index]
14054
+ // prev[index] = tail
14055
+ // next[tail] = index
14056
+ // tail = index
14057
+ if (index !== this.#tail) {
14058
+ if (index === this.#head) {
14059
+ this.#head = this.#next[index]
14060
+ } else {
14061
+ this.#connect(this.#prev[index], this.#next[index])
14062
+ }
14063
+ this.#connect(this.#tail, index)
14064
+ this.#tail = index
14065
+ }
14066
+ }
14067
+ /**
14068
+ * Deletes a key out of the cache.
14069
+ *
14070
+ * Returns true if the key was deleted, false otherwise.
14071
+ */
14072
+ delete(k) {
14073
+ return this.#delete(k, 'delete')
14074
+ }
14075
+ #delete(k, reason) {
14076
+ let deleted = false
14077
+ if (this.#size !== 0) {
14078
+ const index = this.#keyMap.get(k)
14079
+ if (index !== undefined) {
14080
+ deleted = true
14081
+ if (this.#size === 1) {
14082
+ this.#clear(reason)
14083
+ } else {
14084
+ this.#removeItemSize(index)
14085
+ const v = this.#valList[index]
14086
+ if (this.#isBackgroundFetch(v)) {
14087
+ v.__abortController.abort(new Error('deleted'))
14088
+ } else if (this.#hasDispose || this.#hasDisposeAfter) {
14089
+ if (this.#hasDispose) {
14090
+ this.#dispose?.(v, k, reason)
14091
+ }
14092
+ if (this.#hasDisposeAfter) {
14093
+ this.#disposed?.push([v, k, reason])
14094
+ }
14095
+ }
14096
+ this.#keyMap.delete(k)
14097
+ this.#keyList[index] = undefined
14098
+ this.#valList[index] = undefined
14099
+ if (index === this.#tail) {
14100
+ this.#tail = this.#prev[index]
14101
+ } else if (index === this.#head) {
14102
+ this.#head = this.#next[index]
14103
+ } else {
14104
+ const pi = this.#prev[index]
14105
+ this.#next[pi] = this.#next[index]
14106
+ const ni = this.#next[index]
14107
+ this.#prev[ni] = this.#prev[index]
14108
+ }
14109
+ this.#size--
14110
+ this.#free.push(index)
14111
+ }
14112
+ }
14113
+ }
14114
+ if (this.#hasDisposeAfter && this.#disposed?.length) {
14115
+ const dt = this.#disposed
14116
+ let task
14117
+ while ((task = dt?.shift())) {
14118
+ this.#disposeAfter?.(...task)
14119
+ }
14120
+ }
14121
+ return deleted
14122
+ }
14123
+ /**
14124
+ * Clear the cache entirely, throwing away all values.
14125
+ */
14126
+ clear() {
14127
+ return this.#clear('delete')
14128
+ }
14129
+ #clear(reason) {
14130
+ for (const index of this.#rindexes({
14131
+ allowStale: true
14132
+ })) {
14133
+ const v = this.#valList[index]
14134
+ if (this.#isBackgroundFetch(v)) {
14135
+ v.__abortController.abort(new Error('deleted'))
14136
+ } else {
14137
+ const k = this.#keyList[index]
14138
+ if (this.#hasDispose) {
14139
+ this.#dispose?.(v, k, reason)
14140
+ }
14141
+ if (this.#hasDisposeAfter) {
14142
+ this.#disposed?.push([v, k, reason])
14143
+ }
14144
+ }
14145
+ }
14146
+ this.#keyMap.clear()
14147
+ this.#valList.fill(undefined)
14148
+ this.#keyList.fill(undefined)
14149
+ if (this.#ttls && this.#starts) {
14150
+ this.#ttls.fill(0)
14151
+ this.#starts.fill(0)
14152
+ }
14153
+ if (this.#sizes) {
14154
+ this.#sizes.fill(0)
14155
+ }
14156
+ this.#head = 0
14157
+ this.#tail = 0
14158
+ this.#free.length = 0
14159
+ this.#calculatedSize = 0
14160
+ this.#size = 0
14161
+ if (this.#hasDisposeAfter && this.#disposed) {
14162
+ const dt = this.#disposed
14163
+ let task
14164
+ while ((task = dt?.shift())) {
14165
+ this.#disposeAfter?.(...task)
14166
+ }
14167
+ }
14168
+ }
14169
+ }
14170
+ commonjs.LRUCache = LRUCache
14171
+ return commonjs
14172
+ }
14173
+
14174
+ let hasRequiredCommonjs$1
14175
+ function requireCommonjs$1() {
14176
+ if (hasRequiredCommonjs$1) {
14177
+ return commonjs$1
14178
+ }
14179
+ hasRequiredCommonjs$1 = 1
14180
+ const __createBinding =
14181
+ (this && this.__createBinding) ||
14182
+ (Object.create
14183
+ ? function (o, m, k, k2) {
14184
+ if (k2 === undefined) {
14185
+ k2 = k
14186
+ }
14187
+ let desc = Object.getOwnPropertyDescriptor(m, k)
14188
+ if (
14189
+ !desc ||
14190
+ ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)
14191
+ ) {
14192
+ desc = {
14193
+ enumerable: true,
14194
+ get: function () {
14195
+ return m[k]
14196
+ }
14197
+ }
14198
+ }
14199
+ Object.defineProperty(o, k2, desc)
14200
+ }
14201
+ : function (o, m, k, k2) {
14202
+ if (k2 === undefined) {
14203
+ k2 = k
14204
+ }
14205
+ o[k2] = m[k]
14206
+ })
14207
+ const __setModuleDefault =
14208
+ (this && this.__setModuleDefault) ||
14209
+ (Object.create
14210
+ ? function (o, v) {
14211
+ Object.defineProperty(o, 'default', {
14212
+ enumerable: true,
14213
+ value: v
14214
+ })
14215
+ }
14216
+ : function (o, v) {
14217
+ o['default'] = v
14218
+ })
14219
+ const __importStar =
14220
+ (this && this.__importStar) ||
14221
+ function (mod) {
14222
+ if (mod && mod.__esModule) {
14223
+ return mod
14224
+ }
14225
+ const result = {}
14226
+ if (mod != null) {
14227
+ for (var k in mod)
14228
+ if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k))
14229
+ __createBinding(result, mod, k)
14230
+ }
14231
+ __setModuleDefault(result, mod)
14232
+ return result
14233
+ }
14234
+ Object.defineProperty(commonjs$1, '__esModule', {
14235
+ value: true
14236
+ })
14237
+ commonjs$1.PathScurry =
14238
+ commonjs$1.Path =
14239
+ commonjs$1.PathScurryDarwin =
14240
+ commonjs$1.PathScurryPosix =
14241
+ commonjs$1.PathScurryWin32 =
14242
+ commonjs$1.PathScurryBase =
14243
+ commonjs$1.PathPosix =
14244
+ commonjs$1.PathWin32 =
14245
+ commonjs$1.PathBase =
14246
+ commonjs$1.ChildrenCache =
14247
+ commonjs$1.ResolveCache =
14248
+ void 0
14249
+ const lru_cache_1 = /*@__PURE__*/ requireCommonjs$2()
14250
+ const node_path_1 = require$$1$3
14251
+ const node_url_1 = require$$2$3
14252
+ const fs_1 = require$$2$2
14253
+ const actualFS = __importStar(require$$4$1)
14254
+ const realpathSync = fs_1.realpathSync.native
14255
+ // TODO: test perf of fs/promises realpath vs realpathCB,
14256
+ // since the promises one uses realpath.native
14257
+ const promises_1 = require$$5
14258
+ const minipass_1 = requireCommonjs$7()
14259
+ const defaultFS = {
14260
+ lstatSync: fs_1.lstatSync,
14261
+ readdir: fs_1.readdir,
14262
+ readdirSync: fs_1.readdirSync,
14263
+ readlinkSync: fs_1.readlinkSync,
14264
+ realpathSync,
14265
+ promises: {
14266
+ lstat: promises_1.lstat,
14267
+ readdir: promises_1.readdir,
14268
+ readlink: promises_1.readlink,
14269
+ realpath: promises_1.realpath
14270
+ }
14271
+ }
14272
+ // if they just gave us require('fs') then use our default
14273
+ const fsFromOption = fsOption =>
14274
+ !fsOption || fsOption === defaultFS || fsOption === actualFS
14275
+ ? defaultFS
14276
+ : {
14277
+ ...defaultFS,
12599
14278
  ...fsOption,
12600
14279
  promises: {
12601
14280
  ...defaultFS.promises,
@@ -12683,7 +14362,7 @@ function requireCommonjs$1() {
12683
14362
  })
12684
14363
  }
12685
14364
  }
12686
- commonjs.ResolveCache = ResolveCache
14365
+ commonjs$1.ResolveCache = ResolveCache
12687
14366
  // In order to prevent blowing out the js heap by allocating hundreds of
12688
14367
  // thousands of Path entries when walking extremely large trees, the "children"
12689
14368
  // in this tree are represented by storing an array of Path entries in an
@@ -12708,7 +14387,7 @@ function requireCommonjs$1() {
12708
14387
  })
12709
14388
  }
12710
14389
  }
12711
- commonjs.ChildrenCache = ChildrenCache
14390
+ commonjs$1.ChildrenCache = ChildrenCache
12712
14391
  const setAsCwd = Symbol('PathScurry setAsCwd')
12713
14392
  /**
12714
14393
  * Path objects are sort of like a super-powered
@@ -12859,6 +14538,8 @@ function requireCommonjs$1() {
12859
14538
  /**
12860
14539
  * Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
12861
14540
  * this property refers to the *parent* path, not the path object itself.
14541
+ *
14542
+ * @deprecated
12862
14543
  */
12863
14544
  get path() {
12864
14545
  return this.parentPath
@@ -13780,7 +15461,7 @@ function requireCommonjs$1() {
13780
15461
  }
13781
15462
  }
13782
15463
  }
13783
- commonjs.PathBase = PathBase
15464
+ commonjs$1.PathBase = PathBase
13784
15465
  /**
13785
15466
  * Path class used on win32 systems
13786
15467
  *
@@ -13856,7 +15537,7 @@ function requireCommonjs$1() {
13856
15537
  return rootPath === compare
13857
15538
  }
13858
15539
  }
13859
- commonjs.PathWin32 = PathWin32
15540
+ commonjs$1.PathWin32 = PathWin32
13860
15541
  /**
13861
15542
  * Path class used on all posix systems.
13862
15543
  *
@@ -13907,7 +15588,7 @@ function requireCommonjs$1() {
13907
15588
  )
13908
15589
  }
13909
15590
  }
13910
- commonjs.PathPosix = PathPosix
15591
+ commonjs$1.PathPosix = PathPosix
13911
15592
  /**
13912
15593
  * The base class for all PathScurry classes, providing the interface for path
13913
15594
  * resolution and filesystem operations.
@@ -14555,7 +16236,7 @@ function requireCommonjs$1() {
14555
16236
  this.cwd[setAsCwd](oldCwd)
14556
16237
  }
14557
16238
  }
14558
- commonjs.PathScurryBase = PathScurryBase
16239
+ commonjs$1.PathScurryBase = PathScurryBase
14559
16240
  /**
14560
16241
  * Windows implementation of {@link PathScurryBase}
14561
16242
  *
@@ -14612,7 +16293,7 @@ function requireCommonjs$1() {
14612
16293
  )
14613
16294
  }
14614
16295
  }
14615
- commonjs.PathScurryWin32 = PathScurryWin32
16296
+ commonjs$1.PathScurryWin32 = PathScurryWin32
14616
16297
  /**
14617
16298
  * {@link PathScurryBase} implementation for all posix systems other than Darwin.
14618
16299
  *
@@ -14662,7 +16343,7 @@ function requireCommonjs$1() {
14662
16343
  return p.startsWith('/')
14663
16344
  }
14664
16345
  }
14665
- commonjs.PathScurryPosix = PathScurryPosix
16346
+ commonjs$1.PathScurryPosix = PathScurryPosix
14666
16347
  /**
14667
16348
  * {@link PathScurryBase} implementation for Darwin (macOS) systems.
14668
16349
  *
@@ -14680,26 +16361,26 @@ function requireCommonjs$1() {
14680
16361
  })
14681
16362
  }
14682
16363
  }
14683
- commonjs.PathScurryDarwin = PathScurryDarwin
16364
+ commonjs$1.PathScurryDarwin = PathScurryDarwin
14684
16365
  /**
14685
16366
  * Default {@link PathBase} implementation for the current platform.
14686
16367
  *
14687
16368
  * {@link PathWin32} on Windows systems, {@link PathPosix} on all others.
14688
16369
  */
14689
- commonjs.Path = process.platform === 'win32' ? PathWin32 : PathPosix
16370
+ commonjs$1.Path = process.platform === 'win32' ? PathWin32 : PathPosix
14690
16371
  /**
14691
16372
  * Default {@link PathScurryBase} implementation for the current platform.
14692
16373
  *
14693
16374
  * {@link PathScurryWin32} on Windows systems, {@link PathScurryDarwin} on
14694
16375
  * Darwin (macOS) systems, {@link PathScurryPosix} on all others.
14695
16376
  */
14696
- commonjs.PathScurry =
16377
+ commonjs$1.PathScurry =
14697
16378
  process.platform === 'win32'
14698
16379
  ? PathScurryWin32
14699
16380
  : process.platform === 'darwin'
14700
16381
  ? PathScurryDarwin
14701
16382
  : PathScurryPosix
14702
- return commonjs
16383
+ return commonjs$1
14703
16384
  }
14704
16385
 
14705
16386
  const pattern = {}
@@ -14715,7 +16396,7 @@ function requirePattern() {
14715
16396
  value: true
14716
16397
  })
14717
16398
  pattern.Pattern = void 0
14718
- const minimatch_1 = requireCommonjs$2()
16399
+ const minimatch_1 = requireCommonjs$3()
14719
16400
  const isPatternList = pl => pl.length >= 1
14720
16401
  const isGlobList = gl => gl.length >= 1
14721
16402
  /**
@@ -14953,7 +16634,7 @@ function requireIgnore() {
14953
16634
  value: true
14954
16635
  })
14955
16636
  ignore.Ignore = void 0
14956
- const minimatch_1 = requireCommonjs$2()
16637
+ const minimatch_1 = requireCommonjs$3()
14957
16638
  const pattern_js_1 = requirePattern()
14958
16639
  const defaultPlatform =
14959
16640
  typeof process === 'object' &&
@@ -15095,7 +16776,7 @@ function requireProcessor() {
15095
16776
  processor.MatchRecord =
15096
16777
  processor.HasWalkedCache =
15097
16778
  void 0
15098
- const minimatch_1 = requireCommonjs$2()
16779
+ const minimatch_1 = requireCommonjs$3()
15099
16780
  /**
15100
16781
  * A cache of which patterns have been processed for a given Path
15101
16782
  */
@@ -15410,7 +17091,7 @@ function requireWalker() {
15410
17091
  *
15411
17092
  * @module
15412
17093
  */
15413
- const minipass_1 = requireCommonjs$4()
17094
+ const minipass_1 = requireCommonjs$7()
15414
17095
  const ignore_js_1 = requireIgnore()
15415
17096
  const processor_js_1 = requireProcessor()
15416
17097
  const makeIgnore = (ignore, opts) =>
@@ -15840,7 +17521,7 @@ function requireGlob$1() {
15840
17521
  value: true
15841
17522
  })
15842
17523
  glob.Glob = void 0
15843
- const minimatch_1 = requireCommonjs$2()
17524
+ const minimatch_1 = requireCommonjs$3()
15844
17525
  const node_url_1 = require$$2$3
15845
17526
  const path_scurry_1 = requireCommonjs$1()
15846
17527
  const pattern_js_1 = requirePattern()
@@ -16111,7 +17792,7 @@ function requireHasMagic() {
16111
17792
  value: true
16112
17793
  })
16113
17794
  hasMagic.hasMagic = void 0
16114
- const minimatch_1 = requireCommonjs$2()
17795
+ const minimatch_1 = requireCommonjs$3()
16115
17796
  /**
16116
17797
  * Return true if the patterns provided contain any magic glob characters,
16117
17798
  * given the options provided.
@@ -16141,7 +17822,7 @@ function requireHasMagic() {
16141
17822
  let hasRequiredCommonjs
16142
17823
  function requireCommonjs() {
16143
17824
  if (hasRequiredCommonjs) {
16144
- return commonjs$2
17825
+ return commonjs$5
16145
17826
  }
16146
17827
  hasRequiredCommonjs = 1
16147
17828
  ;(function (exports) {
@@ -16165,10 +17846,10 @@ function requireCommonjs() {
16165
17846
  exports.globSync = globSync
16166
17847
  exports.globIterateSync = globIterateSync
16167
17848
  exports.globIterate = globIterate
16168
- const minimatch_1 = requireCommonjs$2()
17849
+ const minimatch_1 = requireCommonjs$3()
16169
17850
  const glob_js_1 = requireGlob$1()
16170
17851
  const has_magic_js_1 = requireHasMagic()
16171
- const minimatch_2 = requireCommonjs$2()
17852
+ const minimatch_2 = requireCommonjs$3()
16172
17853
  Object.defineProperty(exports, 'escape', {
16173
17854
  enumerable: true,
16174
17855
  get: function () {
@@ -16251,8 +17932,8 @@ function requireCommonjs() {
16251
17932
  unescape: minimatch_1.unescape
16252
17933
  })
16253
17934
  exports.glob.glob = exports.glob
16254
- })(commonjs$2)
16255
- return commonjs$2
17935
+ })(commonjs$5)
17936
+ return commonjs$5
16256
17937
  }
16257
17938
 
16258
17939
  let glob_1