@nxtedition/lib 19.4.1 → 19.4.3

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.
Files changed (3) hide show
  1. package/couch.js +4 -1
  2. package/package.json +1 -1
  3. package/sequence.js +14 -1
package/couch.js CHANGED
@@ -952,7 +952,10 @@ class ErrorHandler extends undici.DecoratorHandler {
952
952
 
953
953
  this.#error = new Error(statusText ?? statusCode)
954
954
 
955
- this.#contentType = parseContentType(this.#headers['content-type'] ?? '')?.type
955
+ this.#contentType = this.#headers['content-type']
956
+ ? parseContentType(this.#headers['content-type'] ?? '')?.type
957
+ : null
958
+
956
959
  if (this.#contentType !== 'application/json' && this.#contentType !== 'plain/text') {
957
960
  throw this.#error
958
961
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "19.4.1",
3
+ "version": "19.4.3",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
package/sequence.js CHANGED
@@ -24,7 +24,7 @@ export class Sequence {
24
24
  #parts = []
25
25
  #identity
26
26
 
27
- constructor(value) {
27
+ constructor(value, identity) {
28
28
  try {
29
29
  if (Array.isArray(value)) {
30
30
  for (const part of value) {
@@ -53,6 +53,19 @@ export class Sequence {
53
53
  } else {
54
54
  assert(false)
55
55
  }
56
+
57
+ if (identity != null) {
58
+ if (typeof identity === 'string') {
59
+ assert(identity === this.identity)
60
+ } else if (Array.isArray(identity)) {
61
+ for (let n = 0; n < identity.length; n++) {
62
+ const id = typeof identity[n] === 'string' ? identity[n] : identity[n]?.id
63
+ assert(id === this.#parts[n * 2])
64
+ }
65
+ } else {
66
+ assert(false)
67
+ }
68
+ }
56
69
  } catch (err) {
57
70
  throw Object.assign(new Error('Invalid sequence value'), { cause: err, data: value })
58
71
  }