@nxtedition/lib 21.4.2 → 21.5.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/sequence.js +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "21.4.2",
3
+ "version": "21.5.0",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
package/sequence.js CHANGED
@@ -60,6 +60,11 @@ export class Sequence {
60
60
  const sequence = parseInt(sequenceStr)
61
61
  assert(Number.isFinite(sequence) && sequence >= 0)
62
62
  this.#parts.push(id, sequence)
63
+ } else if (typeof part === 'number') {
64
+ assert(Number.isFinite(part) && part >= 0)
65
+ assert(Number.isFinite(identity))
66
+ this.#parts.push('', part)
67
+ this.#identity = identity
63
68
  } else {
64
69
  assert(Number.isFinite(part.sequence) && part.sequence >= 0)
65
70
  assert(typeof part.id === 'string' && part.id.length > 0)
@@ -128,8 +133,14 @@ export class Sequence {
128
133
  }
129
134
  }
130
135
 
131
- compare(other) {
136
+ compare(other, strict) {
137
+ if (strict === undefined) {
138
+ strict = true
139
+ }
140
+
132
141
  assert(other instanceof Sequence)
142
+ assert(typeof strict === 'boolean')
143
+ assert(!strict && other.identity === this.identity)
133
144
 
134
145
  if (this.#parts.length !== other.#parts.length) {
135
146
  return this.#parts.length - other.#parts.length