@fluidframework/merge-tree 0.59.2001 → 0.59.3000
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/.eslintrc.js +0 -1
- package/dist/client.d.ts +15 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +60 -34
- package/dist/client.js.map +1 -1
- package/dist/collections.d.ts +7 -1
- package/dist/collections.d.ts.map +1 -1
- package/dist/collections.js +27 -1
- package/dist/collections.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/localReference.d.ts +104 -10
- package/dist/localReference.d.ts.map +1 -1
- package/dist/localReference.js +152 -96
- package/dist/localReference.js.map +1 -1
- package/dist/mergeTree.d.ts +28 -21
- package/dist/mergeTree.d.ts.map +1 -1
- package/dist/mergeTree.js +100 -88
- package/dist/mergeTree.js.map +1 -1
- package/dist/partialLengths.js +10 -10
- package/dist/partialLengths.js.map +1 -1
- package/dist/referencePositions.d.ts +55 -0
- package/dist/referencePositions.d.ts.map +1 -0
- package/dist/referencePositions.js +93 -0
- package/dist/referencePositions.js.map +1 -0
- package/dist/segmentGroupCollection.js +1 -1
- package/dist/segmentGroupCollection.js.map +1 -1
- package/dist/segmentPropertiesManager.js +5 -5
- package/dist/segmentPropertiesManager.js.map +1 -1
- package/dist/snapshotChunks.js.map +1 -1
- package/dist/snapshotLoader.d.ts.map +1 -1
- package/dist/snapshotLoader.js +9 -9
- package/dist/snapshotLoader.js.map +1 -1
- package/dist/snapshotV1.js +7 -7
- package/dist/snapshotV1.js.map +1 -1
- package/dist/snapshotlegacy.js +6 -6
- package/dist/snapshotlegacy.js.map +1 -1
- package/dist/sortedSegmentSet.d.ts.map +1 -1
- package/dist/sortedSegmentSet.js +1 -1
- package/dist/sortedSegmentSet.js.map +1 -1
- package/dist/textSegment.js +3 -2
- package/dist/textSegment.js.map +1 -1
- package/lib/client.d.ts +15 -4
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +31 -5
- package/lib/client.js.map +1 -1
- package/lib/collections.d.ts +7 -1
- package/lib/collections.d.ts.map +1 -1
- package/lib/collections.js +26 -1
- package/lib/collections.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/localReference.d.ts +104 -10
- package/lib/localReference.d.ts.map +1 -1
- package/lib/localReference.js +146 -90
- package/lib/localReference.js.map +1 -1
- package/lib/mergeTree.d.ts +28 -21
- package/lib/mergeTree.d.ts.map +1 -1
- package/lib/mergeTree.js +67 -51
- package/lib/mergeTree.js.map +1 -1
- package/lib/referencePositions.d.ts +55 -0
- package/lib/referencePositions.d.ts.map +1 -0
- package/lib/referencePositions.js +80 -0
- package/lib/referencePositions.js.map +1 -0
- package/lib/segmentPropertiesManager.js.map +1 -1
- package/lib/snapshotChunks.js.map +1 -1
- package/lib/snapshotLoader.d.ts.map +1 -1
- package/lib/snapshotLoader.js.map +1 -1
- package/lib/snapshotV1.js.map +1 -1
- package/lib/snapshotlegacy.js +1 -1
- package/lib/snapshotlegacy.js.map +1 -1
- package/lib/sortedSegmentSet.d.ts.map +1 -1
- package/lib/sortedSegmentSet.js +1 -1
- package/lib/sortedSegmentSet.js.map +1 -1
- package/lib/textSegment.js +3 -2
- package/lib/textSegment.js.map +1 -1
- package/package.json +161 -14
- package/src/client.ts +45 -19
- package/src/collections.ts +55 -54
- package/src/index.ts +1 -0
- package/src/localReference.ts +190 -100
- package/src/mergeTree.ts +107 -99
- package/src/referencePositions.ts +126 -0
- package/src/snapshotChunks.ts +8 -8
- package/src/snapshotLoader.ts +4 -4
- package/src/snapshotV1.ts +1 -1
- package/src/snapshotlegacy.ts +2 -2
- package/src/sortedSegmentSet.ts +4 -4
- package/src/textSegment.ts +2 -2
package/src/collections.ts
CHANGED
|
@@ -35,14 +35,12 @@ export class Stack<T> {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function ListRemoveEntry<U>(entry: List<U>): List<U> | undefined {
|
|
38
|
+
export function ListRemoveEntry<U>(entry: List<U>): List<U> | undefined {
|
|
39
39
|
if (entry === undefined) {
|
|
40
40
|
return undefined;
|
|
41
|
-
}
|
|
42
|
-
else if (entry.isHead) {
|
|
41
|
+
} else if (entry.isHead) {
|
|
43
42
|
return undefined;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
43
|
+
} else {
|
|
46
44
|
entry.next.prev = entry.prev;
|
|
47
45
|
entry.prev.next = entry.next;
|
|
48
46
|
}
|
|
@@ -61,7 +59,7 @@ export class List<T> {
|
|
|
61
59
|
public next: List<T>;
|
|
62
60
|
public prev: List<T>;
|
|
63
61
|
|
|
64
|
-
constructor(public isHead: boolean,
|
|
62
|
+
constructor(public isHead: boolean, public data: T | undefined) {
|
|
65
63
|
this.prev = this;
|
|
66
64
|
this.next = this;
|
|
67
65
|
}
|
|
@@ -146,7 +144,14 @@ export class List<T> {
|
|
|
146
144
|
return (this.next === this);
|
|
147
145
|
}
|
|
148
146
|
|
|
147
|
+
/**
|
|
148
|
+
* @deprecated - use unshift
|
|
149
|
+
*/
|
|
149
150
|
public push(data: T): void {
|
|
151
|
+
this.unshift(data);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
public unshift(data: T): void {
|
|
150
155
|
const entry = ListMakeEntry(data);
|
|
151
156
|
entry.data = data;
|
|
152
157
|
entry.isHead = false;
|
|
@@ -155,6 +160,26 @@ export class List<T> {
|
|
|
155
160
|
this.next = entry;
|
|
156
161
|
entry.next.prev = entry;
|
|
157
162
|
}
|
|
163
|
+
|
|
164
|
+
public [Symbol.iterator]() {
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
166
|
+
let node: List<T> | undefined = this;
|
|
167
|
+
const iterator: IterableIterator<T> = {
|
|
168
|
+
next(): IteratorResult<T> {
|
|
169
|
+
while (node && node.next.isHead === false) {
|
|
170
|
+
node = node.next;
|
|
171
|
+
if (node.data !== undefined) {
|
|
172
|
+
return { value: node.data, done: false };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return { value: undefined, done: true };
|
|
176
|
+
},
|
|
177
|
+
[Symbol.iterator]() {
|
|
178
|
+
return this;
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
return iterator;
|
|
182
|
+
}
|
|
158
183
|
}
|
|
159
184
|
|
|
160
185
|
export interface Comparer<T> {
|
|
@@ -286,11 +311,9 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
286
311
|
const cmp = this.compareKeys(key, _node.key);
|
|
287
312
|
if (cmp < 0) {
|
|
288
313
|
_node = _node.left;
|
|
289
|
-
}
|
|
290
|
-
else if (cmp > 0) {
|
|
314
|
+
} else if (cmp > 0) {
|
|
291
315
|
_node = _node.right;
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
316
|
+
} else {
|
|
294
317
|
return _node;
|
|
295
318
|
}
|
|
296
319
|
}
|
|
@@ -387,8 +410,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
387
410
|
if (key !== undefined) {
|
|
388
411
|
if (data === undefined) {
|
|
389
412
|
this.remove(key);
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
413
|
+
} else {
|
|
392
414
|
this.root = this.nodePut(this.root, key, data, conflict);
|
|
393
415
|
this.root.color = RBColor.BLACK;
|
|
394
416
|
}
|
|
@@ -403,16 +425,13 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
403
425
|
let _node = node;
|
|
404
426
|
if (!_node) {
|
|
405
427
|
return this.makeNode(key, data, RBColor.RED, 1);
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
428
|
+
} else {
|
|
408
429
|
const cmp = this.compareKeys(key, _node.key);
|
|
409
430
|
if (cmp < 0) {
|
|
410
431
|
_node.left = this.nodePut(_node.left, key, data, conflict);
|
|
411
|
-
}
|
|
412
|
-
else if (cmp > 0) {
|
|
432
|
+
} else if (cmp > 0) {
|
|
413
433
|
_node.right = this.nodePut(_node.right, key, data, conflict);
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
434
|
+
} else {
|
|
416
435
|
if (conflict) {
|
|
417
436
|
const kd = conflict(key, _node.key, data, _node.data);
|
|
418
437
|
if (kd.key) {
|
|
@@ -423,8 +442,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
423
442
|
} else {
|
|
424
443
|
_node.data = data;
|
|
425
444
|
}
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
445
|
+
} else {
|
|
428
446
|
_node.data = data;
|
|
429
447
|
}
|
|
430
448
|
}
|
|
@@ -504,8 +522,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
504
522
|
}
|
|
505
523
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
506
524
|
_node.left = this.nodeRemove(_node.left!, key);
|
|
507
|
-
}
|
|
508
|
-
else {
|
|
525
|
+
} else {
|
|
509
526
|
if (this.isRed(_node.left)) {
|
|
510
527
|
_node = this.rotateRight(_node);
|
|
511
528
|
}
|
|
@@ -523,8 +540,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
523
540
|
_node.data = subtreeMin.data;
|
|
524
541
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
525
542
|
_node.right = this.nodeRemoveMin(_node.right!);
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
543
|
+
} else {
|
|
528
544
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
529
545
|
_node.right = this.nodeRemove(_node.right!, key);
|
|
530
546
|
}
|
|
@@ -543,16 +559,13 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
543
559
|
const cmp = this.compareKeys(key, node.key);
|
|
544
560
|
if (cmp === 0) {
|
|
545
561
|
return node;
|
|
546
|
-
}
|
|
547
|
-
else if (cmp < 0) {
|
|
562
|
+
} else if (cmp < 0) {
|
|
548
563
|
return this.nodeFloor(node.left, key);
|
|
549
|
-
}
|
|
550
|
-
else {
|
|
564
|
+
} else {
|
|
551
565
|
const rightFloor = this.nodeFloor(node.right, key);
|
|
552
566
|
if (rightFloor) {
|
|
553
567
|
return rightFloor;
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
568
|
+
} else {
|
|
556
569
|
return node;
|
|
557
570
|
}
|
|
558
571
|
}
|
|
@@ -570,16 +583,13 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
570
583
|
const cmp = this.compareKeys(key, node.key);
|
|
571
584
|
if (cmp === 0) {
|
|
572
585
|
return node;
|
|
573
|
-
}
|
|
574
|
-
else if (cmp > 0) {
|
|
586
|
+
} else if (cmp > 0) {
|
|
575
587
|
return this.nodeCeil(node.right, key);
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
588
|
+
} else {
|
|
578
589
|
const leftCeil = this.nodeCeil(node.left, key);
|
|
579
590
|
if (leftCeil) {
|
|
580
591
|
return leftCeil;
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
592
|
+
} else {
|
|
583
593
|
return node;
|
|
584
594
|
}
|
|
585
595
|
}
|
|
@@ -595,8 +605,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
595
605
|
private nodeMin(node: RBNode<TKey, TData>): RBNode<TKey, TData> {
|
|
596
606
|
if (!node.left) {
|
|
597
607
|
return node;
|
|
598
|
-
}
|
|
599
|
-
else {
|
|
608
|
+
} else {
|
|
600
609
|
return this.nodeMin(node.left);
|
|
601
610
|
}
|
|
602
611
|
}
|
|
@@ -610,8 +619,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
|
|
|
610
619
|
private nodeMax(node: RBNode<TKey, TData>): RBNode<TKey, TData> {
|
|
611
620
|
if (!node.right) {
|
|
612
621
|
return node;
|
|
613
|
-
}
|
|
614
|
-
else {
|
|
622
|
+
} else {
|
|
615
623
|
return this.nodeMax(node.right);
|
|
616
624
|
}
|
|
617
625
|
}
|
|
@@ -985,14 +993,11 @@ export class TST<T> {
|
|
|
985
993
|
const c = key.charAt(d);
|
|
986
994
|
if (c < x.c) {
|
|
987
995
|
return this.nodeGet(x.left, key, d);
|
|
988
|
-
}
|
|
989
|
-
else if (c > x.c) {
|
|
996
|
+
} else if (c > x.c) {
|
|
990
997
|
return this.nodeGet(x.right, key, d);
|
|
991
|
-
}
|
|
992
|
-
else if (d < (key.length - 1)) {
|
|
998
|
+
} else if (d < (key.length - 1)) {
|
|
993
999
|
return this.nodeGet(x.mid, key, d + 1);
|
|
994
|
-
}
|
|
995
|
-
else { return x; }
|
|
1000
|
+
} else { return x; }
|
|
996
1001
|
}
|
|
997
1002
|
|
|
998
1003
|
public put(key: string, val: T) {
|
|
@@ -1010,14 +1015,11 @@ export class TST<T> {
|
|
|
1010
1015
|
}
|
|
1011
1016
|
if (c < _x.c) {
|
|
1012
1017
|
_x.left = this.nodePut(_x.left, key, val, d);
|
|
1013
|
-
}
|
|
1014
|
-
else if (c > _x.c) {
|
|
1018
|
+
} else if (c > _x.c) {
|
|
1015
1019
|
_x.right = this.nodePut(_x.right, key, val, d);
|
|
1016
|
-
}
|
|
1017
|
-
else if (d < (key.length - 1)) {
|
|
1020
|
+
} else if (d < (key.length - 1)) {
|
|
1018
1021
|
_x.mid = this.nodePut(_x.mid, key, val, d + 1);
|
|
1019
|
-
}
|
|
1020
|
-
else {
|
|
1022
|
+
} else {
|
|
1021
1023
|
_x.val = val;
|
|
1022
1024
|
}
|
|
1023
1025
|
return _x;
|
|
@@ -1124,8 +1126,7 @@ export class TST<T> {
|
|
|
1124
1126
|
const recurD = (d < (pattern.length - 1)) ? d + 1 : d;
|
|
1125
1127
|
if (c === x.c) {
|
|
1126
1128
|
this.nodeProximity(x.mid, { text: prefix.text + x.c }, recurD, pattern, distance, q);
|
|
1127
|
-
}
|
|
1128
|
-
else {
|
|
1129
|
+
} else {
|
|
1129
1130
|
this.nodeProximity(x.mid, { text: prefix.text + x.c }, recurD, pattern, distance - 1, q);
|
|
1130
1131
|
}
|
|
1131
1132
|
if ((distance > 0) || (c > x.c)) {
|
package/src/index.ts
CHANGED