@forsakringskassan/vite-lib-config 3.6.5 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3967,14 +3967,14 @@ var Stack = class _Stack {
3967
3967
  }
3968
3968
  };
3969
3969
  var LRUCache = class _LRUCache {
3970
- // properties coming in from the options of these, only max and maxSize
3971
- // really *need* to be protected. The rest can be modified, as they just
3972
- // set defaults for various methods.
3970
+ // options that cannot be changed without disaster
3973
3971
  #max;
3974
3972
  #maxSize;
3975
3973
  #dispose;
3974
+ #onInsert;
3976
3975
  #disposeAfter;
3977
3976
  #fetchMethod;
3977
+ #memoMethod;
3978
3978
  /**
3979
3979
  * {@link LRUCache.OptionsBase.ttl}
3980
3980
  */
@@ -4053,6 +4053,7 @@ var LRUCache = class _LRUCache {
4053
4053
  #hasDispose;
4054
4054
  #hasFetchMethod;
4055
4055
  #hasDisposeAfter;
4056
+ #hasOnInsert;
4056
4057
  /**
4057
4058
  * Do not call this method unless you need to inspect the
4058
4059
  * inner workings of the cache. If anything returned by this
@@ -4120,12 +4121,21 @@ var LRUCache = class _LRUCache {
4120
4121
  get fetchMethod() {
4121
4122
  return this.#fetchMethod;
4122
4123
  }
4124
+ get memoMethod() {
4125
+ return this.#memoMethod;
4126
+ }
4123
4127
  /**
4124
4128
  * {@link LRUCache.OptionsBase.dispose} (read-only)
4125
4129
  */
4126
4130
  get dispose() {
4127
4131
  return this.#dispose;
4128
4132
  }
4133
+ /**
4134
+ * {@link LRUCache.OptionsBase.onInsert} (read-only)
4135
+ */
4136
+ get onInsert() {
4137
+ return this.#onInsert;
4138
+ }
4129
4139
  /**
4130
4140
  * {@link LRUCache.OptionsBase.disposeAfter} (read-only)
4131
4141
  */
@@ -4133,7 +4143,7 @@ var LRUCache = class _LRUCache {
4133
4143
  return this.#disposeAfter;
4134
4144
  }
4135
4145
  constructor(options) {
4136
- const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort } = options;
4146
+ 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 } = options;
4137
4147
  if (max !== 0 && !isPosInt(max)) {
4138
4148
  throw new TypeError("max option must be a nonnegative integer");
4139
4149
  }
@@ -4153,6 +4163,10 @@ var LRUCache = class _LRUCache {
4153
4163
  throw new TypeError("sizeCalculation set to non-function");
4154
4164
  }
4155
4165
  }
4166
+ if (memoMethod !== void 0 && typeof memoMethod !== "function") {
4167
+ throw new TypeError("memoMethod must be a function if defined");
4168
+ }
4169
+ this.#memoMethod = memoMethod;
4156
4170
  if (fetchMethod !== void 0 && typeof fetchMethod !== "function") {
4157
4171
  throw new TypeError("fetchMethod must be a function if specified");
4158
4172
  }
@@ -4171,6 +4185,9 @@ var LRUCache = class _LRUCache {
4171
4185
  if (typeof dispose === "function") {
4172
4186
  this.#dispose = dispose;
4173
4187
  }
4188
+ if (typeof onInsert === "function") {
4189
+ this.#onInsert = onInsert;
4190
+ }
4174
4191
  if (typeof disposeAfter === "function") {
4175
4192
  this.#disposeAfter = disposeAfter;
4176
4193
  this.#disposed = [];
@@ -4179,6 +4196,7 @@ var LRUCache = class _LRUCache {
4179
4196
  this.#disposed = void 0;
4180
4197
  }
4181
4198
  this.#hasDispose = !!this.#dispose;
4199
+ this.#hasOnInsert = !!this.#onInsert;
4182
4200
  this.#hasDisposeAfter = !!this.#disposeAfter;
4183
4201
  this.noDisposeOnSet = !!noDisposeOnSet;
4184
4202
  this.noUpdateTTL = !!noUpdateTTL;
@@ -4223,7 +4241,8 @@ var LRUCache = class _LRUCache {
4223
4241
  }
4224
4242
  }
4225
4243
  /**
4226
- * Return the remaining TTL time for a given entry key
4244
+ * Return the number of ms left in the item's TTL. If item is not in cache,
4245
+ * returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
4227
4246
  */
4228
4247
  getRemainingTTL(key) {
4229
4248
  return this.#keyMap.has(key) ? Infinity : 0;
@@ -4239,7 +4258,7 @@ var LRUCache = class _LRUCache {
4239
4258
  if (ttl !== 0 && this.ttlAutopurge) {
4240
4259
  const t = setTimeout(() => {
4241
4260
  if (this.#isStale(index)) {
4242
- this.delete(this.#keyList[index]);
4261
+ this.#delete(this.#keyList[index], "expire");
4243
4262
  }
4244
4263
  }, ttl + 1);
4245
4264
  if (t.unref) {
@@ -4476,13 +4495,14 @@ var LRUCache = class _LRUCache {
4476
4495
  return this.entries();
4477
4496
  }
4478
4497
  /**
4479
- * A String value that is used in the creation of the default string description of an object.
4480
- * Called by the built-in method Object.prototype.toString.
4498
+ * A String value that is used in the creation of the default string
4499
+ * description of an object. Called by the built-in method
4500
+ * `Object.prototype.toString`.
4481
4501
  */
4482
4502
  [Symbol.toStringTag] = "LRUCache";
4483
4503
  /**
4484
4504
  * Find a value for which the supplied fn method returns a truthy value,
4485
- * similar to Array.find(). fn is called as fn(value, key, cache).
4505
+ * similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
4486
4506
  */
4487
4507
  find(fn, getOptions = {}) {
4488
4508
  for (const i of this.#indexes()) {
@@ -4496,10 +4516,15 @@ var LRUCache = class _LRUCache {
4496
4516
  }
4497
4517
  }
4498
4518
  /**
4499
- * Call the supplied function on each item in the cache, in order from
4500
- * most recently used to least recently used. fn is called as
4501
- * fn(value, key, cache). Does not update age or recenty of use.
4502
- * Does not iterate over stale values.
4519
+ * Call the supplied function on each item in the cache, in order from most
4520
+ * recently used to least recently used.
4521
+ *
4522
+ * `fn` is called as `fn(value, key, cache)`.
4523
+ *
4524
+ * If `thisp` is provided, function will be called in the `this`-context of
4525
+ * the provided object, or the cache if no `thisp` object is provided.
4526
+ *
4527
+ * Does not update age or recenty of use, or iterate over stale values.
4503
4528
  */
4504
4529
  forEach(fn, thisp = this) {
4505
4530
  for (const i of this.#indexes()) {
@@ -4531,7 +4556,7 @@ var LRUCache = class _LRUCache {
4531
4556
  let deleted = false;
4532
4557
  for (const i of this.#rindexes({ allowStale: true })) {
4533
4558
  if (this.#isStale(i)) {
4534
- this.delete(this.#keyList[i]);
4559
+ this.#delete(this.#keyList[i], "expire");
4535
4560
  deleted = true;
4536
4561
  }
4537
4562
  }
@@ -4539,9 +4564,15 @@ var LRUCache = class _LRUCache {
4539
4564
  }
4540
4565
  /**
4541
4566
  * Get the extended info about a given entry, to get its value, size, and
4542
- * TTL info simultaneously. Like {@link LRUCache#dump}, but just for a
4543
- * single key. Always returns stale values, if their info is found in the
4544
- * cache, so be sure to check for expired TTLs if relevant.
4567
+ * TTL info simultaneously. Returns `undefined` if the key is not present.
4568
+ *
4569
+ * Unlike {@link LRUCache#dump}, which is designed to be portable and survive
4570
+ * serialization, the `start` value is always the current timestamp, and the
4571
+ * `ttl` is a calculated remaining time to live (negative if expired).
4572
+ *
4573
+ * Always returns stale values, if their info is found in the cache, so be
4574
+ * sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
4575
+ * if relevant.
4545
4576
  */
4546
4577
  info(key) {
4547
4578
  const i = this.#keyMap.get(key);
@@ -4568,7 +4599,16 @@ var LRUCache = class _LRUCache {
4568
4599
  }
4569
4600
  /**
4570
4601
  * Return an array of [key, {@link LRUCache.Entry}] tuples which can be
4571
- * passed to cache.load()
4602
+ * passed to {@link LRUCache#load}.
4603
+ *
4604
+ * The `start` fields are calculated relative to a portable `Date.now()`
4605
+ * timestamp, even if `performance.now()` is available.
4606
+ *
4607
+ * Stale entries are always included in the `dump`, even if
4608
+ * {@link LRUCache.OptionsBase.allowStale} is false.
4609
+ *
4610
+ * Note: this returns an actual array, not a generator, so it can be more
4611
+ * easily passed around.
4572
4612
  */
4573
4613
  dump() {
4574
4614
  const arr = [];
@@ -4593,8 +4633,12 @@ var LRUCache = class _LRUCache {
4593
4633
  }
4594
4634
  /**
4595
4635
  * Reset the cache and load in the items in entries in the order listed.
4596
- * Note that the shape of the resulting cache may be different if the
4597
- * same options are not used in both caches.
4636
+ *
4637
+ * The shape of the resulting cache may be different if the same options are
4638
+ * not used in both caches.
4639
+ *
4640
+ * The `start` fields are assumed to be calculated relative to a portable
4641
+ * `Date.now()` timestamp, even if `performance.now()` is available.
4598
4642
  */
4599
4643
  load(arr) {
4600
4644
  this.clear();
@@ -4611,6 +4655,30 @@ var LRUCache = class _LRUCache {
4611
4655
  *
4612
4656
  * Note: if `undefined` is specified as a value, this is an alias for
4613
4657
  * {@link LRUCache#delete}
4658
+ *
4659
+ * Fields on the {@link LRUCache.SetOptions} options param will override
4660
+ * their corresponding values in the constructor options for the scope
4661
+ * of this single `set()` operation.
4662
+ *
4663
+ * If `start` is provided, then that will set the effective start
4664
+ * time for the TTL calculation. Note that this must be a previous
4665
+ * value of `performance.now()` if supported, or a previous value of
4666
+ * `Date.now()` if not.
4667
+ *
4668
+ * Options object may also include `size`, which will prevent
4669
+ * calling the `sizeCalculation` function and just use the specified
4670
+ * number if it is a positive integer, and `noDisposeOnSet` which
4671
+ * will prevent calling a `dispose` function in the case of
4672
+ * overwrites.
4673
+ *
4674
+ * If the `size` (or return value of `sizeCalculation`) for a given
4675
+ * entry is greater than `maxEntrySize`, then the item will not be
4676
+ * added to the cache.
4677
+ *
4678
+ * Will update the recency of the entry.
4679
+ *
4680
+ * If the value is `undefined`, then this is an alias for
4681
+ * `cache.delete(key)`. `undefined` is never stored in the cache.
4614
4682
  */
4615
4683
  set(k, v, setOptions = {}) {
4616
4684
  if (v === void 0) {
@@ -4625,7 +4693,7 @@ var LRUCache = class _LRUCache {
4625
4693
  status.set = "miss";
4626
4694
  status.maxEntrySizeExceeded = true;
4627
4695
  }
4628
- this.delete(k);
4696
+ this.#delete(k, "set");
4629
4697
  return this;
4630
4698
  }
4631
4699
  let index = this.#size === 0 ? void 0 : this.#keyMap.get(k);
@@ -4642,6 +4710,9 @@ var LRUCache = class _LRUCache {
4642
4710
  if (status)
4643
4711
  status.set = "add";
4644
4712
  noUpdateTTL = false;
4713
+ if (this.#hasOnInsert) {
4714
+ this.#onInsert?.(v, k, "add");
4715
+ }
4645
4716
  } else {
4646
4717
  this.#moveToTail(index);
4647
4718
  const oldVal = this.#valList[index];
@@ -4677,6 +4748,9 @@ var LRUCache = class _LRUCache {
4677
4748
  } else if (status) {
4678
4749
  status.set = "update";
4679
4750
  }
4751
+ if (this.#hasOnInsert) {
4752
+ this.onInsert?.(v, k, v === oldVal ? "update" : "replace");
4753
+ }
4680
4754
  }
4681
4755
  if (ttl !== 0 && !this.#ttls) {
4682
4756
  this.#initializeTTLTracking();
@@ -4759,6 +4833,14 @@ var LRUCache = class _LRUCache {
4759
4833
  * Will return false if the item is stale, even though it is technically
4760
4834
  * in the cache.
4761
4835
  *
4836
+ * Check if a key is in the cache, without updating the recency of
4837
+ * use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
4838
+ * to `true` in either the options or the constructor.
4839
+ *
4840
+ * Will return `false` if the item is stale, even though it is technically in
4841
+ * the cache. The difference can be determined (if it matters) by using a
4842
+ * `status` argument, and inspecting the `has` field.
4843
+ *
4762
4844
  * Will not update item age unless
4763
4845
  * {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
4764
4846
  */
@@ -4841,7 +4923,7 @@ var LRUCache = class _LRUCache {
4841
4923
  if (bf2.__staleWhileFetching) {
4842
4924
  this.#valList[index] = bf2.__staleWhileFetching;
4843
4925
  } else {
4844
- this.delete(k);
4926
+ this.#delete(k, "fetch");
4845
4927
  }
4846
4928
  } else {
4847
4929
  if (options.status)
@@ -4867,7 +4949,7 @@ var LRUCache = class _LRUCache {
4867
4949
  if (this.#valList[index] === p) {
4868
4950
  const del = !noDelete || bf2.__staleWhileFetching === void 0;
4869
4951
  if (del) {
4870
- this.delete(k);
4952
+ this.#delete(k, "fetch");
4871
4953
  } else if (!allowStaleAborted) {
4872
4954
  this.#valList[index] = bf2.__staleWhileFetching;
4873
4955
  }
@@ -5005,6 +5087,28 @@ var LRUCache = class _LRUCache {
5005
5087
  return staleVal ? p.__staleWhileFetching : p.__returned = p;
5006
5088
  }
5007
5089
  }
5090
+ async forceFetch(k, fetchOptions = {}) {
5091
+ const v = await this.fetch(k, fetchOptions);
5092
+ if (v === void 0)
5093
+ throw new Error("fetch() returned undefined");
5094
+ return v;
5095
+ }
5096
+ memo(k, memoOptions = {}) {
5097
+ const memoMethod = this.#memoMethod;
5098
+ if (!memoMethod) {
5099
+ throw new Error("no memoMethod provided to constructor");
5100
+ }
5101
+ const { context, forceRefresh, ...options } = memoOptions;
5102
+ const v = this.get(k, options);
5103
+ if (!forceRefresh && v !== void 0)
5104
+ return v;
5105
+ const vv = memoMethod(k, v, {
5106
+ options,
5107
+ context
5108
+ });
5109
+ this.set(k, vv, options);
5110
+ return vv;
5111
+ }
5008
5112
  /**
5009
5113
  * Return a value from the cache. Will update the recency of the cache
5010
5114
  * entry found.
@@ -5024,7 +5128,7 @@ var LRUCache = class _LRUCache {
5024
5128
  status.get = "stale";
5025
5129
  if (!fetching) {
5026
5130
  if (!noDeleteOnStaleGet) {
5027
- this.delete(k);
5131
+ this.#delete(k, "expire");
5028
5132
  }
5029
5133
  if (status && allowStale)
5030
5134
  status.returnedStale = true;
@@ -5068,16 +5172,20 @@ var LRUCache = class _LRUCache {
5068
5172
  }
5069
5173
  /**
5070
5174
  * Deletes a key out of the cache.
5175
+ *
5071
5176
  * Returns true if the key was deleted, false otherwise.
5072
5177
  */
5073
5178
  delete(k) {
5179
+ return this.#delete(k, "delete");
5180
+ }
5181
+ #delete(k, reason) {
5074
5182
  let deleted = false;
5075
5183
  if (this.#size !== 0) {
5076
5184
  const index = this.#keyMap.get(k);
5077
5185
  if (index !== void 0) {
5078
5186
  deleted = true;
5079
5187
  if (this.#size === 1) {
5080
- this.clear();
5188
+ this.#clear(reason);
5081
5189
  } else {
5082
5190
  this.#removeItemSize(index);
5083
5191
  const v = this.#valList[index];
@@ -5085,10 +5193,10 @@ var LRUCache = class _LRUCache {
5085
5193
  v.__abortController.abort(new Error("deleted"));
5086
5194
  } else if (this.#hasDispose || this.#hasDisposeAfter) {
5087
5195
  if (this.#hasDispose) {
5088
- this.#dispose?.(v, k, "delete");
5196
+ this.#dispose?.(v, k, reason);
5089
5197
  }
5090
5198
  if (this.#hasDisposeAfter) {
5091
- this.#disposed?.push([v, k, "delete"]);
5199
+ this.#disposed?.push([v, k, reason]);
5092
5200
  }
5093
5201
  }
5094
5202
  this.#keyMap.delete(k);
@@ -5122,6 +5230,9 @@ var LRUCache = class _LRUCache {
5122
5230
  * Clear the cache entirely, throwing away all values.
5123
5231
  */
5124
5232
  clear() {
5233
+ return this.#clear("delete");
5234
+ }
5235
+ #clear(reason) {
5125
5236
  for (const index of this.#rindexes({ allowStale: true })) {
5126
5237
  const v = this.#valList[index];
5127
5238
  if (this.#isBackgroundFetch(v)) {
@@ -5129,10 +5240,10 @@ var LRUCache = class _LRUCache {
5129
5240
  } else {
5130
5241
  const k = this.#keyList[index];
5131
5242
  if (this.#hasDispose) {
5132
- this.#dispose?.(v, k, "delete");
5243
+ this.#dispose?.(v, k, reason);
5133
5244
  }
5134
5245
  if (this.#hasDisposeAfter) {
5135
- this.#disposed?.push([v, k, "delete"]);
5246
+ this.#disposed?.push([v, k, reason]);
5136
5247
  }
5137
5248
  }
5138
5249
  }
@@ -6260,6 +6371,8 @@ var PathBase = class {
6260
6371
  /**
6261
6372
  * Deprecated alias for Dirent['parentPath'] Somewhat counterintuitively,
6262
6373
  * this property refers to the *parent* path, not the path object itself.
6374
+ *
6375
+ * @deprecated
6263
6376
  */
6264
6377
  get path() {
6265
6378
  return this.parentPath;
@@ -9115,7 +9228,8 @@ function createDedent(options) {
9115
9228
  function dedent2(strings, ...values) {
9116
9229
  const raw = typeof strings === "string" ? [strings] : strings.raw;
9117
9230
  const {
9118
- escapeSpecialCharacters = Array.isArray(strings)
9231
+ escapeSpecialCharacters = Array.isArray(strings),
9232
+ trimWhitespace = true
9119
9233
  } = options;
9120
9234
  let result = "";
9121
9235
  for (let i = 0; i < raw.length; i++) {
@@ -9145,7 +9259,9 @@ function createDedent(options) {
9145
9259
  const m = mindent;
9146
9260
  result = lines.map((l) => l[0] === " " || l[0] === " " ? l.slice(m) : l).join("\n");
9147
9261
  }
9148
- result = result.trim();
9262
+ if (trimWhitespace) {
9263
+ result = result.trim();
9264
+ }
9149
9265
  if (escapeSpecialCharacters) {
9150
9266
  result = result.replace(/\\n/g, "\n");
9151
9267
  }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.5"
8
+ "packageVersion": "7.52.7"
9
9
  }
10
10
  ]
11
11
  }