@nxtedition/lib 26.4.4 → 26.4.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "26.4.4",
3
+ "version": "26.4.5",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
package/rxjs/auditMap.js CHANGED
@@ -5,6 +5,7 @@ function auditMapImpl(project) {
5
5
  let pendingValue = null
6
6
  let hasPendingValue = false
7
7
  let isComplete = false
8
+ let abortController = null
8
9
 
9
10
  let innerSubscription = null
10
11
  let outerSubscription = null
@@ -15,6 +16,7 @@ function auditMapImpl(project) {
15
16
 
16
17
  function _innerComplete() {
17
18
  innerSubscription = null
19
+ abortController = null
18
20
 
19
21
  if (hasPendingValue) {
20
22
  const value = pendingValue
@@ -30,9 +32,30 @@ function auditMapImpl(project) {
30
32
  o.next(val)
31
33
  }
32
34
 
35
+ function _drain() {
36
+ if (!hasPendingValue) {
37
+ return
38
+ }
39
+ const value = pendingValue
40
+ pendingValue = null
41
+ hasPendingValue = false
42
+ return { value }
43
+ }
44
+
33
45
  function _tryNext(value) {
34
46
  try {
35
- const result = project(value)
47
+ const result = project(value, {
48
+ get signal() {
49
+ if (!abortController) {
50
+ abortController = new AbortController()
51
+ if (hasPendingValue) {
52
+ abortController.abort()
53
+ }
54
+ }
55
+ return abortController.signal
56
+ },
57
+ _drain,
58
+ })
36
59
  const observable = typeof result.then === 'function' ? from(result) : result
37
60
  innerSubscription = observable.subscribe({
38
61
  next: _innerNext,
@@ -51,6 +74,7 @@ function auditMapImpl(project) {
51
74
  if (innerSubscription) {
52
75
  pendingValue = value
53
76
  hasPendingValue = true
77
+ abortController?.abort()
54
78
  } else {
55
79
  _tryNext(value)
56
80
  }
@@ -60,6 +84,8 @@ function auditMapImpl(project) {
60
84
  isComplete = true
61
85
  if (!innerSubscription) {
62
86
  o.complete()
87
+ } else {
88
+ abortController?.abort()
63
89
  }
64
90
  }
65
91
 
@@ -0,0 +1,64 @@
1
+ import { test } from 'node:test'
2
+ import assert from 'node:assert'
3
+ import auditMap from './auditMap.js'
4
+ import * as rxjs from 'rxjs'
5
+ import tp from 'node:timers/promises'
6
+
7
+ test('auditMap sync', (t) => {
8
+ t.plan(1, { wait: true })
9
+ rxjs
10
+ .of(1, 2, 3)
11
+ .pipe(
12
+ auditMap((val) => rxjs.of(val * 2)),
13
+ rxjs.toArray(),
14
+ )
15
+ .subscribe((val) => {
16
+ t.assert.deepStrictEqual(val, [2, 4, 6])
17
+ })
18
+ })
19
+
20
+ test('auditMap async', (t) => {
21
+ t.plan(1, { wait: true })
22
+ rxjs
23
+ .of(1, 2, 3)
24
+ .pipe(
25
+ auditMap(async (val) => val * 2),
26
+ rxjs.toArray(),
27
+ )
28
+ .subscribe((val) => {
29
+ t.assert.deepStrictEqual(val, [2, 6])
30
+ })
31
+ })
32
+
33
+ test('auditMap drain', (t) => {
34
+ t.plan(1, { wait: true })
35
+ rxjs
36
+ .of(1, 2, 3)
37
+ .pipe(
38
+ auditMap(async (val, { _drain }) => {
39
+ await tp.setTimeout(1)
40
+ return _drain()?.value ?? val
41
+ }),
42
+ rxjs.toArray(),
43
+ )
44
+ .subscribe((val) => {
45
+ t.assert.deepStrictEqual(val, [3])
46
+ })
47
+ })
48
+
49
+ test('auditMap signal', (t) => {
50
+ t.plan(1, { wait: true })
51
+ rxjs
52
+ .of(1, 2, 3)
53
+ .pipe(
54
+ auditMap(async (val, { signal }) => {
55
+ await tp.setTimeout(1)
56
+ assert.strictEqual(signal.aborted, val === 1)
57
+ return val
58
+ }),
59
+ rxjs.toArray(),
60
+ )
61
+ .subscribe((val) => {
62
+ t.assert.deepStrictEqual(val, [1, 3])
63
+ })
64
+ })
package/s3.js CHANGED
@@ -327,7 +327,16 @@ function getTransformedHeaders(headers) {
327
327
  */
328
328
  const transformedHeaders = {}
329
329
 
330
+ const isRangedResponse = headers['content-range'] != null
331
+
330
332
  for (const name of Object.keys(headers)) {
333
+ // Google Cloud S3 returns checksums for the full object
334
+ // even with range requests, which causes checksum mismatches.
335
+ // I assume the checksum headers shouldn't be sent with ranged responses.
336
+ if (isRangedResponse && /^x-amz-checksum-/i.test(name)) {
337
+ continue
338
+ }
339
+
331
340
  const headerValues = headers[name]
332
341
  transformedHeaders[name] = Array.isArray(headerValues)
333
342
  ? headerValues.join(',')