@nxtedition/lib 23.5.2 → 23.5.4

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.
package/cache.js CHANGED
@@ -2,6 +2,7 @@ import { LRUCache } from 'lru-cache'
2
2
 
3
3
  export class AsyncCache {
4
4
  #lru
5
+ #prefix
5
6
  #valueSelector
6
7
  #keySelector
7
8
  #dedupe = new Map()
@@ -12,7 +13,7 @@ export class AsyncCache {
12
13
  this.#lru = new LRUCache({ max: 1024 })
13
14
 
14
15
  if (typeof location === 'string') {
15
- // Do nothing...
16
+ this.#prefix = location + ':'
16
17
  } else {
17
18
  throw new TypeError('location must be undefined or a string')
18
19
  }
@@ -57,10 +58,10 @@ export class AsyncCache {
57
58
 
58
59
  let cached = this.#lru.get(key)
59
60
 
60
- // if (!cached) {
61
- // const raw = globalThis.localStorage.getItem(this.#prefix + key)
62
- // cached = raw ? JSON.parse(raw) : null
63
- // }
61
+ if (!cached) {
62
+ const raw = globalThis.localStorage.getItem(this.#prefix + key)
63
+ cached = raw ? JSON.parse(raw) : null
64
+ }
64
65
 
65
66
  if (cached) {
66
67
  if (Date.now() < cached.expire) {
@@ -107,8 +108,7 @@ export class AsyncCache {
107
108
  value,
108
109
  }
109
110
 
110
- // globalThis.localStorage.setItem(this.#prefix + key, JSON.stringify(cached))
111
-
111
+ globalThis.localStorage.setItem(this.#prefix + key, JSON.stringify(cached))
112
112
  this.#lru.set(key, cached)
113
113
  }
114
114
 
package/errors.d.ts CHANGED
@@ -2,7 +2,8 @@ export class AbortError extends Error {
2
2
  constructor(message: string)
3
3
  }
4
4
 
5
- export function parseError(err: unknown): Error | null
5
+ type Falsy = false | 0 | 0n | '' | null | undefined
6
+ export function parseError<Err>(err: Err): Err extends Falsy ? null : Error
6
7
 
7
8
  export interface NxtError {
8
9
  message: string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "23.5.2",
3
+ "version": "23.5.4",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
package/s3.js CHANGED
@@ -84,12 +84,12 @@ class UndiciRequestHandler extends NodeHttpHandler {
84
84
  *
85
85
  * @param {Object} options - The options for the upload.
86
86
  * @param {AWS.S3} options.client - The S3 client.
87
- * @param {AbortSignal} options.signal - The signal to abort the upload.
88
- * @param {Object} options.logger - The logger to use.
87
+ * @param {AbortSignal} [options.signal] - The signal to abort the upload.
88
+ * @param {Object} [options.logger] - The logger to use.
89
89
  * @param {number} [options.partSize=16e6] - The size of each part in the multipart upload.
90
90
  * @param {PQueue} [options.queue] - The queue to use for part uploads.
91
91
  * @param {CreateMultipartUploadRequest & {
92
- * Body: Buffer | NodeJS.ReadStream,
92
+ * Body: stream.Readable,
93
93
  * ContentMD5?: string,
94
94
  * ContentLength?: number,
95
95
  * }} options.params - The parameters for the upload.
package/serializers.js CHANGED
@@ -247,7 +247,7 @@ function errSerializer(err) {
247
247
  _err.aggregateErrors = errors
248
248
  }
249
249
 
250
- if (!Object.prototype.hasOwnProperty.call(err.cause, seen)) {
250
+ if (isErrorLike(err.cause) && !Object.prototype.hasOwnProperty.call(err.cause, seen)) {
251
251
  _err.cause = errSerializer(err.cause)
252
252
  }
253
253