@nxtedition/lib 27.0.6 → 27.0.7

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 (2) hide show
  1. package/package.json +2 -2
  2. package/sequence.js +16 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "27.0.6",
3
+ "version": "27.0.7",
4
4
  "license": "UNLICENSED",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -92,5 +92,5 @@
92
92
  "pino": ">=7.0.0",
93
93
  "rxjs": "^7.0.0"
94
94
  },
95
- "gitHead": "0a3d683b790eeeb5f198316a27e205f84bf93c9e"
95
+ "gitHead": "fe6494737e2cd14d2e75b5cfc702b23f08cc2c34"
96
96
  }
package/sequence.js CHANGED
@@ -108,13 +108,23 @@ export class Sequence {
108
108
  } else if (typeof value === 'string') {
109
109
  const [countStr, token] = value.split('-')
110
110
  const count = parseInt(countStr)
111
- assert(Number.isFinite(count) && count >= 0)
112
- for (const str of token.split('_')) {
113
- const [sequenceStr, id] = str.split(ID_SEP)
114
- const sequence = parseInt(sequenceStr)
115
- assert(Number.isFinite(sequence) && sequence >= 0)
116
- this.#parts.push(id, sequence)
111
+ if (!Number.isFinite(count) || count < 0) {
112
+ throw new Error('invalid sequence count')
117
113
  }
114
+
115
+ if (token) {
116
+ for (const str of token.split('_')) {
117
+ const [sequenceStr, id] = str.split(ID_SEP)
118
+ const sequence = parseInt(sequenceStr)
119
+ if (!Number.isFinite(sequence) || sequence < 0) {
120
+ throw new Error('invalid sequence part')
121
+ }
122
+ this.#parts.push(id, sequence)
123
+ }
124
+ } else if (count > 0) {
125
+ throw new Error('invalid sequence parts')
126
+ }
127
+
118
128
  this.#count = count
119
129
  this.#value = value
120
130
  } else if (value instanceof Sequence) {