@nxtedition/lib 21.6.2 → 21.7.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.
package/couch.js CHANGED
@@ -119,7 +119,7 @@ export function makeCouch(opts) {
119
119
  * @param {string} [options.since=null] - The sequence number to start from.
120
120
  * @param {number} [options.highWaterMark=128 * 1024] - Buffering.
121
121
  * @param {object} [options.selector=null] - The selector to filter changes.
122
- * @yields {Array<{ id: string, seq?: string, doc?: Object, deleted?: boolean, changes: Array<{ rev: string }> }>}
122
+ * @return {AsyncGenerator<Array<{ id: string, seq?: string, doc?: Object, deleted?: boolean, changes: Array<{ rev: string }>}> & { lastSeq: string | null | 0 }}
123
123
  */
124
124
  async function* changes({ client = defaultClient, signal = null, logger, ...options } = {}) {
125
125
  const params = {}
package/merge-ranges.js CHANGED
@@ -29,7 +29,13 @@ export default function mergeRanges(ranges) {
29
29
  const range = ranges[n]
30
30
  const top = stack[stack.length - 1]
31
31
 
32
- if (range.length !== 2 || !Number.isFinite(range[0]) || !Number.isFinite(range[1])) {
32
+ if (
33
+ !Array.isArray(range) ||
34
+ range.length !== 2 ||
35
+ !Number.isFinite(range[0]) ||
36
+ !Number.isFinite(range[1]) ||
37
+ range[0] > range[1]
38
+ ) {
33
39
  continue
34
40
  }
35
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "21.6.2",
3
+ "version": "21.7.0",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
package/s3.js CHANGED
@@ -10,13 +10,13 @@ const QUEUE = new PQueue({ concurrency: 8 })
10
10
  const MD5_HEX_EXPR = /^[A-F0-9]{32}$/i
11
11
 
12
12
  /**
13
- * @typedef {import('undici').Dispatcher} Dispatcher
14
- * @typedef {import('@aws-sdk/client-s3').S3ClientConfig & {dispatcher?: Dispatcher}} S3ClientConfig
13
+ * @import { Dispatcher } from 'undici'
14
+ * @import { S3ClientConfig, CreateMultipartUploadRequest } from '@aws-sdk/client-s3'
15
15
  */
16
16
 
17
17
  export class S3Client extends AWS.S3Client {
18
18
  /**
19
- * @param {S3ClientConfig} config
19
+ * @param {S3ClientConfig & { dispatcher?: Dispatcher }} config
20
20
  */
21
21
  constructor(config) {
22
22
  const { dispatcher, ...options } = config
@@ -79,12 +79,11 @@ class UndiciRequestHandler extends NodeHttpHandler {
79
79
  * @param {Object} options.logger - The logger to use.
80
80
  * @param {number} [options.partSize=16e6] - The size of each part in the multipart upload.
81
81
  * @param {PQueue} [options.queue] - The queue to use for part uploads.
82
- * @param {Object} options.params - The parameters for the upload.
83
- * @param {Buffer|NodeJS.ReadStream} options.params.Body - The data to upload.
84
- * @param {string} options.params.Key - The key of the object.
85
- * @param {string} options.params.Bucket - The name of the bucket.
86
- * @param {string} [options.params.ContentMD5] - The MD5 hash of the object as base64 string.
87
- * @param {number} [options.params.ContentLength] - The length of the object.
82
+ * @param {CreateMultipartUploadRequest & {
83
+ * Body: Buffer | NodeJS.ReadStream,
84
+ * ContentMD5?: string,
85
+ * ContentLength?: number,
86
+ * }} options.params - The parameters for the upload.
88
87
  * @returns {Promise<Object>} The result of the upload.
89
88
  */
90
89
  export async function upload({
@@ -107,7 +106,7 @@ export async function upload({
107
106
  throw new Error('Invalid params')
108
107
  }
109
108
 
110
- const { Body, Key, Bucket, ContentMD5, ContentLength } = params
109
+ const { Body, Key, Bucket, ContentMD5, ContentLength, ...createMultipartParams } = params
111
110
 
112
111
  const size = ContentLength != null ? Number(ContentLength) : null
113
112
 
@@ -144,7 +143,7 @@ export async function upload({
144
143
  }
145
144
 
146
145
  const multipartUploadOutput = await s3.send(
147
- new AWS.CreateMultipartUploadCommand({ Bucket, Key }),
146
+ new AWS.CreateMultipartUploadCommand({ ...createMultipartParams, Bucket, Key }),
148
147
  { abortSignal: uploader.signal },
149
148
  )
150
149
  uploader.signal.throwIfAborted()
package/sequence.js CHANGED
@@ -50,7 +50,7 @@ export class Sequence {
50
50
  a = new Sequence(a)
51
51
  }
52
52
 
53
- if (a && typeof b === 'string') {
53
+ if (typeof b === 'string') {
54
54
  b = new Sequence(b)
55
55
  }
56
56