@sovereignbase/convergent-replicated-list 1.3.3 → 1.3.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/README.md +208 -227
- package/dist/index.cjs +146 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +121 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -276,6 +276,93 @@ function trySpliceInsertedParent(crListReplica, insertedEntries, reparentedEntri
|
|
|
276
276
|
return true;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
+
// src/.helpers/trySpliceReplacement/index.ts
|
|
280
|
+
function trySpliceReplacement(crListReplica, insertedEntries, reparentedEntries, tombstoneCount) {
|
|
281
|
+
if (tombstoneCount === 0 || insertedEntries.length !== 1 || reparentedEntries.length > 1)
|
|
282
|
+
return false;
|
|
283
|
+
const inserted = insertedEntries[0];
|
|
284
|
+
const predecessor = inserted.predecessor === "\0" ? void 0 : crListReplica.parentMap.get(inserted.predecessor);
|
|
285
|
+
if (inserted.predecessor !== "\0" && !predecessor) return false;
|
|
286
|
+
const siblings = crListReplica.childrenMap.get(inserted.predecessor);
|
|
287
|
+
if (_optionalChain([siblings, 'optionalAccess', _20 => _20.length]) !== 1 || siblings[0] !== inserted) return false;
|
|
288
|
+
const reparented = reparentedEntries[0];
|
|
289
|
+
const next = _optionalChain([reparented, 'optionalAccess', _21 => _21.entry]);
|
|
290
|
+
if (next) {
|
|
291
|
+
const children = crListReplica.childrenMap.get(inserted.uuidv7);
|
|
292
|
+
if (next.predecessor !== inserted.uuidv7 || !crListReplica.tombstones.has(reparented.previousPredecessor) || _optionalChain([children, 'optionalAccess', _22 => _22.length]) !== 1 || children[0] !== next || next.prev !== predecessor)
|
|
293
|
+
return false;
|
|
294
|
+
} else if (_optionalChain([crListReplica, 'access', _23 => _23.childrenMap, 'access', _24 => _24.get, 'call', _25 => _25(inserted.uuidv7), 'optionalAccess', _26 => _26.length])) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
if (predecessor) {
|
|
298
|
+
if (predecessor.next !== next) return false;
|
|
299
|
+
} else {
|
|
300
|
+
let reachable = 0;
|
|
301
|
+
let current2 = next;
|
|
302
|
+
while (current2) {
|
|
303
|
+
reachable++;
|
|
304
|
+
current2 = current2.next;
|
|
305
|
+
}
|
|
306
|
+
if (reachable !== crListReplica.parentMap.size - 1) return false;
|
|
307
|
+
}
|
|
308
|
+
const expectedIndex = predecessor ? predecessor.index + 1 : 0;
|
|
309
|
+
void linkEntryBetween(predecessor, inserted, next);
|
|
310
|
+
let current = inserted;
|
|
311
|
+
let index = expectedIndex;
|
|
312
|
+
while (current) {
|
|
313
|
+
current.index = index;
|
|
314
|
+
index++;
|
|
315
|
+
current = current.next;
|
|
316
|
+
}
|
|
317
|
+
crListReplica.index = /* @__PURE__ */ new Map([[inserted.index, inserted]]);
|
|
318
|
+
crListReplica.cursor = inserted;
|
|
319
|
+
crListReplica.cursorIndex = inserted.index;
|
|
320
|
+
crListReplica.size = crListReplica.parentMap.size;
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// src/.helpers/trySpliceSiblingInsert/index.ts
|
|
325
|
+
function trySpliceSiblingInsert(crListReplica, insertedEntries, reparentedEntries, tombstoneCount) {
|
|
326
|
+
if (tombstoneCount !== 0 || insertedEntries.length !== 1 || reparentedEntries.length !== 0)
|
|
327
|
+
return false;
|
|
328
|
+
const inserted = insertedEntries[0];
|
|
329
|
+
if (inserted.predecessor === "\0") return false;
|
|
330
|
+
if (_optionalChain([crListReplica, 'access', _27 => _27.childrenMap, 'access', _28 => _28.get, 'call', _29 => _29(inserted.uuidv7), 'optionalAccess', _30 => _30.length])) return false;
|
|
331
|
+
const predecessor = crListReplica.parentMap.get(inserted.predecessor);
|
|
332
|
+
const siblings = crListReplica.childrenMap.get(inserted.predecessor);
|
|
333
|
+
if (!predecessor || !siblings || siblings.length < 2) return false;
|
|
334
|
+
void siblings.sort((a, b) => a.uuidv7 > b.uuidv7 ? 1 : -1);
|
|
335
|
+
const siblingIndex = siblings.indexOf(inserted);
|
|
336
|
+
if (siblingIndex === -1) return false;
|
|
337
|
+
const lastSibling = siblings[siblings.length - 1];
|
|
338
|
+
if (lastSibling !== inserted && lastSibling.next) return false;
|
|
339
|
+
const previousSibling = siblings[siblingIndex - 1];
|
|
340
|
+
const nextSibling = siblings[siblingIndex + 1];
|
|
341
|
+
if (_optionalChain([previousSibling, 'optionalAccess', _31 => _31.uuidv7])) {
|
|
342
|
+
if (_optionalChain([crListReplica, 'access', _32 => _32.childrenMap, 'access', _33 => _33.get, 'call', _34 => _34(previousSibling.uuidv7), 'optionalAccess', _35 => _35.length]))
|
|
343
|
+
return false;
|
|
344
|
+
if (previousSibling.next !== nextSibling) return false;
|
|
345
|
+
} else if (predecessor.next !== nextSibling) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
const prev = _nullishCoalesce(previousSibling, () => ( predecessor));
|
|
349
|
+
const next = nextSibling;
|
|
350
|
+
if (next && next.prev !== prev) return false;
|
|
351
|
+
void linkEntryBetween(prev, inserted, next);
|
|
352
|
+
let current = inserted;
|
|
353
|
+
let index = prev.index + 1;
|
|
354
|
+
while (current) {
|
|
355
|
+
current.index = index;
|
|
356
|
+
index++;
|
|
357
|
+
current = current.next;
|
|
358
|
+
}
|
|
359
|
+
crListReplica.index = /* @__PURE__ */ new Map([[inserted.index, inserted]]);
|
|
360
|
+
crListReplica.cursor = inserted;
|
|
361
|
+
crListReplica.cursorIndex = inserted.index;
|
|
362
|
+
crListReplica.size = crListReplica.parentMap.size;
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
|
|
279
366
|
// src/core/crud/create/index.ts
|
|
280
367
|
|
|
281
368
|
function __create(snapshot) {
|
|
@@ -307,11 +394,11 @@ function __create(snapshot) {
|
|
|
307
394
|
);
|
|
308
395
|
if (!linkedListEntry) continue;
|
|
309
396
|
void attachEntryToIndexes(crListReplica, linkedListEntry);
|
|
310
|
-
if (canUseLinearProjection && linkedListEntry.predecessor === (_nullishCoalesce(_optionalChain([previous, 'optionalAccess',
|
|
397
|
+
if (canUseLinearProjection && linkedListEntry.predecessor === (_nullishCoalesce(_optionalChain([previous, 'optionalAccess', _36 => _36.uuidv7]), () => ( "\0")))) {
|
|
311
398
|
linkedListEntry.index = crListReplica.parentMap.size - 1;
|
|
312
399
|
void linkEntryBetween(previous, linkedListEntry, void 0);
|
|
313
400
|
previous = linkedListEntry;
|
|
314
|
-
void _optionalChain([crListReplica, 'access',
|
|
401
|
+
void _optionalChain([crListReplica, 'access', _37 => _37.index, 'optionalAccess', _38 => _38.set, 'call', _39 => _39(linkedListEntry.index, linkedListEntry)]);
|
|
315
402
|
continue;
|
|
316
403
|
}
|
|
317
404
|
canUseLinearProjection = false;
|
|
@@ -330,7 +417,7 @@ function __create(snapshot) {
|
|
|
330
417
|
function __read(targetIndex, crListReplica) {
|
|
331
418
|
try {
|
|
332
419
|
void seekCursorToIndex(targetIndex, crListReplica);
|
|
333
|
-
return _optionalChain([crListReplica, 'access',
|
|
420
|
+
return _optionalChain([crListReplica, 'access', _40 => _40.cursor, 'optionalAccess', _41 => _41.value]);
|
|
334
421
|
} catch (e) {
|
|
335
422
|
return void 0;
|
|
336
423
|
}
|
|
@@ -366,7 +453,7 @@ function __update(listIndex, listValues, crListReplica, mode) {
|
|
|
366
453
|
crListReplica.cursor = linkedListEntry;
|
|
367
454
|
crListReplica.cursorIndex = linkedListEntry.index;
|
|
368
455
|
void attachEntryToIndexes(crListReplica, linkedListEntry, delta);
|
|
369
|
-
_optionalChain([crListReplica, 'access',
|
|
456
|
+
_optionalChain([crListReplica, 'access', _42 => _42.index, 'optionalAccess', _43 => _43.set, 'call', _44 => _44(linkedListEntry.index, linkedListEntry)]);
|
|
370
457
|
change[linkedListEntry.index] = linkedListEntry.value;
|
|
371
458
|
break;
|
|
372
459
|
}
|
|
@@ -382,7 +469,7 @@ function __update(listIndex, listValues, crListReplica, mode) {
|
|
|
382
469
|
void attachEntryToIndexes(crListReplica, linkedListEntry, delta);
|
|
383
470
|
crListReplica.cursor = linkedListEntry;
|
|
384
471
|
crListReplica.cursorIndex = linkedListEntry.index;
|
|
385
|
-
void _optionalChain([crListReplica, 'access',
|
|
472
|
+
void _optionalChain([crListReplica, 'access', _45 => _45.index, 'optionalAccess', _46 => _46.set, 'call', _47 => _47(linkedListEntry.index, linkedListEntry)]);
|
|
386
473
|
change[linkedListEntry.index] = linkedListEntry.value;
|
|
387
474
|
break;
|
|
388
475
|
}
|
|
@@ -409,13 +496,13 @@ function __update(listIndex, listValues, crListReplica, mode) {
|
|
|
409
496
|
}
|
|
410
497
|
void attachEntryToIndexes(crListReplica, linkedListEntry, delta);
|
|
411
498
|
void crListReplica.tombstones.add(entryToOverwrite.uuidv7);
|
|
412
|
-
void _optionalChain([delta, 'access',
|
|
499
|
+
void _optionalChain([delta, 'access', _48 => _48.tombstones, 'optionalAccess', _49 => _49.push, 'call', _50 => _50(entryToOverwrite.uuidv7)]);
|
|
413
500
|
void detachEntryFromIndexes(crListReplica, entryToOverwrite);
|
|
414
501
|
entryToOverwrite.next = void 0;
|
|
415
502
|
entryToOverwrite.prev = void 0;
|
|
416
503
|
crListReplica.cursor = linkedListEntry;
|
|
417
504
|
crListReplica.cursorIndex = actualIndex;
|
|
418
|
-
void _optionalChain([crListReplica, 'access',
|
|
505
|
+
void _optionalChain([crListReplica, 'access', _51 => _51.index, 'optionalAccess', _52 => _52.set, 'call', _53 => _53(linkedListEntry.index, linkedListEntry)]);
|
|
419
506
|
change[actualIndex] = linkedListEntry.value;
|
|
420
507
|
break;
|
|
421
508
|
}
|
|
@@ -424,7 +511,7 @@ function __update(listIndex, listValues, crListReplica, mode) {
|
|
|
424
511
|
crListReplica.cursor = linkedListEntry;
|
|
425
512
|
crListReplica.cursorIndex = linkedListEntry.index;
|
|
426
513
|
void attachEntryToIndexes(crListReplica, linkedListEntry, delta);
|
|
427
|
-
void _optionalChain([crListReplica, 'access',
|
|
514
|
+
void _optionalChain([crListReplica, 'access', _54 => _54.index, 'optionalAccess', _55 => _55.set, 'call', _56 => _56(linkedListEntry.index, linkedListEntry)]);
|
|
428
515
|
change[linkedListEntry.index] = linkedListEntry.value;
|
|
429
516
|
break;
|
|
430
517
|
}
|
|
@@ -453,7 +540,7 @@ function __update(listIndex, listValues, crListReplica, mode) {
|
|
|
453
540
|
crListReplica.cursor = linkedListEntry;
|
|
454
541
|
crListReplica.cursorIndex = linkedListEntry.index;
|
|
455
542
|
if (next) crListReplica.index = /* @__PURE__ */ new Map();
|
|
456
|
-
void _optionalChain([crListReplica, 'access',
|
|
543
|
+
void _optionalChain([crListReplica, 'access', _57 => _57.index, 'optionalAccess', _58 => _58.set, 'call', _59 => _59(linkedListEntry.index, linkedListEntry)]);
|
|
457
544
|
change[linkedListEntry.index] = linkedListEntry.value;
|
|
458
545
|
break;
|
|
459
546
|
}
|
|
@@ -462,7 +549,7 @@ function __update(listIndex, listValues, crListReplica, mode) {
|
|
|
462
549
|
crListReplica.cursor = linkedListEntry;
|
|
463
550
|
crListReplica.cursorIndex = linkedListEntry.index;
|
|
464
551
|
void attachEntryToIndexes(crListReplica, linkedListEntry, delta);
|
|
465
|
-
void _optionalChain([crListReplica, 'access',
|
|
552
|
+
void _optionalChain([crListReplica, 'access', _60 => _60.index, 'optionalAccess', _61 => _61.set, 'call', _62 => _62(linkedListEntry.index, linkedListEntry)]);
|
|
466
553
|
change[linkedListEntry.index] = linkedListEntry.value;
|
|
467
554
|
mode = "after";
|
|
468
555
|
listIndex = linkedListEntry.index - 1;
|
|
@@ -473,7 +560,7 @@ function __update(listIndex, listValues, crListReplica, mode) {
|
|
|
473
560
|
const actualIndex = _nullishCoalesce(crListReplica.cursorIndex, () => ( listIndex));
|
|
474
561
|
const prev = crListReplica.cursor.prev;
|
|
475
562
|
linkedListEntry.index = actualIndex;
|
|
476
|
-
linkedListEntry.predecessor = _nullishCoalesce(_optionalChain([prev, 'optionalAccess',
|
|
563
|
+
linkedListEntry.predecessor = _nullishCoalesce(_optionalChain([prev, 'optionalAccess', _63 => _63.uuidv7]), () => ( "\0"));
|
|
477
564
|
void linkEntryBetween(prev, linkedListEntry, crListReplica.cursor);
|
|
478
565
|
if (crListReplica.cursor.predecessor === linkedListEntry.predecessor) {
|
|
479
566
|
void moveEntryToPredecessor(
|
|
@@ -487,7 +574,7 @@ function __update(listIndex, listValues, crListReplica, mode) {
|
|
|
487
574
|
crListReplica.cursor = linkedListEntry;
|
|
488
575
|
crListReplica.cursorIndex = actualIndex;
|
|
489
576
|
crListReplica.index = /* @__PURE__ */ new Map();
|
|
490
|
-
void _optionalChain([crListReplica, 'access',
|
|
577
|
+
void _optionalChain([crListReplica, 'access', _64 => _64.index, 'optionalAccess', _65 => _65.set, 'call', _66 => _66(linkedListEntry.index, linkedListEntry)]);
|
|
491
578
|
change[actualIndex] = linkedListEntry.value;
|
|
492
579
|
mode = "after";
|
|
493
580
|
listIndex = linkedListEntry.index - 1;
|
|
@@ -514,7 +601,7 @@ function __delete(crListReplica, startIndex, endIndex) {
|
|
|
514
601
|
void seekCursorToIndex(listIndex, crListReplica);
|
|
515
602
|
if (!crListReplica.cursor) return false;
|
|
516
603
|
let current = crListReplica.cursor;
|
|
517
|
-
const predecessor = _nullishCoalesce(_optionalChain([current, 'access',
|
|
604
|
+
const predecessor = _nullishCoalesce(_optionalChain([current, 'access', _67 => _67.prev, 'optionalAccess', _68 => _68.uuidv7]), () => ( "\0"));
|
|
518
605
|
const deletedIds = /* @__PURE__ */ new Set();
|
|
519
606
|
let deleted = 0;
|
|
520
607
|
let currentIndex = _nullishCoalesce(crListReplica.cursorIndex, () => ( listIndex));
|
|
@@ -522,7 +609,7 @@ function __delete(crListReplica, startIndex, endIndex) {
|
|
|
522
609
|
const next = current.next;
|
|
523
610
|
change[currentIndex] = void 0;
|
|
524
611
|
void deletedIds.add(current.uuidv7);
|
|
525
|
-
void _optionalChain([crListReplica, 'access',
|
|
612
|
+
void _optionalChain([crListReplica, 'access', _69 => _69.index, 'optionalAccess', _70 => _70.delete, 'call', _71 => _71(currentIndex)]);
|
|
526
613
|
void deleteLiveEntry(crListReplica, current, delta);
|
|
527
614
|
current = next;
|
|
528
615
|
currentIndex++;
|
|
@@ -542,7 +629,7 @@ function __delete(crListReplica, startIndex, endIndex) {
|
|
|
542
629
|
void deleteLiveEntry(crListReplica, current, delta);
|
|
543
630
|
void linkEntryBetween(prev, replacement, next);
|
|
544
631
|
void attachEntryToIndexes(crListReplica, replacement, delta);
|
|
545
|
-
if (_optionalChain([next, 'optionalAccess',
|
|
632
|
+
if (_optionalChain([next, 'optionalAccess', _72 => _72.predecessor]) === current.uuidv7)
|
|
546
633
|
void moveEntryToPredecessor(
|
|
547
634
|
crListReplica,
|
|
548
635
|
next,
|
|
@@ -571,6 +658,7 @@ function __merge(crListReplica, crListDelta) {
|
|
|
571
658
|
const newTombsIndices = [];
|
|
572
659
|
const reparentedVals = [];
|
|
573
660
|
const change = {};
|
|
661
|
+
let tailTombstoneMovedCursor = false;
|
|
574
662
|
let needsRelink = false;
|
|
575
663
|
if (Object.hasOwn(crListDelta, "values") && Array.isArray(crListDelta.values) && crListDelta.values.length === 1 && (!Object.hasOwn(crListDelta, "tombstones") || Array.isArray(crListDelta.tombstones) && crListDelta.tombstones.length === 0)) {
|
|
576
664
|
const linkedListEntry = materializeSnapshotEntry(
|
|
@@ -587,7 +675,7 @@ function __merge(crListReplica, crListDelta) {
|
|
|
587
675
|
crListReplica.cursorIndex = linkedListEntry.index;
|
|
588
676
|
void attachEntryToIndexes(crListReplica, linkedListEntry);
|
|
589
677
|
crListReplica.size = crListReplica.parentMap.size;
|
|
590
|
-
void _optionalChain([crListReplica, 'access',
|
|
678
|
+
void _optionalChain([crListReplica, 'access', _73 => _73.index, 'optionalAccess', _74 => _74.set, 'call', _75 => _75(linkedListEntry.index, linkedListEntry)]);
|
|
591
679
|
return { [linkedListEntry.index]: linkedListEntry.value };
|
|
592
680
|
}
|
|
593
681
|
}
|
|
@@ -598,15 +686,31 @@ function __merge(crListReplica, crListDelta) {
|
|
|
598
686
|
void crListReplica.tombstones.add(tombstone);
|
|
599
687
|
const linkedListEntry = crListReplica.parentMap.get(tombstone);
|
|
600
688
|
if (linkedListEntry) {
|
|
689
|
+
const wasTail = linkedListEntry.next === void 0;
|
|
690
|
+
const wasCursor = crListReplica.cursor === linkedListEntry;
|
|
601
691
|
void newTombsIndices.push(linkedListEntry.index);
|
|
602
|
-
void _optionalChain([crListReplica, 'access',
|
|
692
|
+
void _optionalChain([crListReplica, 'access', _76 => _76.index, 'optionalAccess', _77 => _77.delete, 'call', _78 => _78(linkedListEntry.index)]);
|
|
603
693
|
void deleteLiveEntry(crListReplica, linkedListEntry);
|
|
694
|
+
tailTombstoneMovedCursor = wasTail && wasCursor;
|
|
604
695
|
needsRelink = true;
|
|
605
696
|
}
|
|
606
697
|
}
|
|
607
698
|
}
|
|
608
|
-
if (!Object.hasOwn(crListDelta, "values") || !Array.isArray(crListDelta.values)) {
|
|
699
|
+
if (!Object.hasOwn(crListDelta, "values") || !Array.isArray(crListDelta.values) || crListDelta.values.length === 0 && tailTombstoneMovedCursor) {
|
|
609
700
|
if (newTombsIndices.length === 0) return false;
|
|
701
|
+
if (newTombsIndices.length === 1 && tailTombstoneMovedCursor) {
|
|
702
|
+
if (crListReplica.cursor) {
|
|
703
|
+
crListReplica.cursorIndex = crListReplica.size - 1;
|
|
704
|
+
void _optionalChain([crListReplica, 'access', _79 => _79.index, 'optionalAccess', _80 => _80.set, 'call', _81 => _81(
|
|
705
|
+
crListReplica.cursorIndex,
|
|
706
|
+
crListReplica.cursor
|
|
707
|
+
)]);
|
|
708
|
+
} else {
|
|
709
|
+
crListReplica.cursorIndex = void 0;
|
|
710
|
+
}
|
|
711
|
+
change[newTombsIndices[0]] = void 0;
|
|
712
|
+
return change;
|
|
713
|
+
}
|
|
610
714
|
void rebuildLiveIndex(crListReplica);
|
|
611
715
|
for (const index of newTombsIndices) {
|
|
612
716
|
change[index] = void 0;
|
|
@@ -644,7 +748,7 @@ function __merge(crListReplica, crListDelta) {
|
|
|
644
748
|
crListReplica.cursor = linkedListEntry;
|
|
645
749
|
crListReplica.cursorIndex = linkedListEntry.index;
|
|
646
750
|
crListReplica.size = crListReplica.parentMap.size;
|
|
647
|
-
void _optionalChain([crListReplica, 'access',
|
|
751
|
+
void _optionalChain([crListReplica, 'access', _82 => _82.index, 'optionalAccess', _83 => _83.set, 'call', _84 => _84(linkedListEntry.index, linkedListEntry)]);
|
|
648
752
|
} else {
|
|
649
753
|
needsRelink = true;
|
|
650
754
|
}
|
|
@@ -655,13 +759,23 @@ function __merge(crListReplica, crListDelta) {
|
|
|
655
759
|
crListReplica.cursor = linkedListEntry;
|
|
656
760
|
crListReplica.cursorIndex = linkedListEntry.index;
|
|
657
761
|
crListReplica.size = crListReplica.parentMap.size;
|
|
658
|
-
void _optionalChain([crListReplica, 'access',
|
|
762
|
+
void _optionalChain([crListReplica, 'access', _85 => _85.index, 'optionalAccess', _86 => _86.set, 'call', _87 => _87(linkedListEntry.index, linkedListEntry)]);
|
|
659
763
|
} else {
|
|
660
764
|
needsRelink = true;
|
|
661
765
|
}
|
|
662
766
|
}
|
|
663
767
|
if (needsRelink) {
|
|
664
|
-
if (!
|
|
768
|
+
if (!trySpliceSiblingInsert(
|
|
769
|
+
crListReplica,
|
|
770
|
+
newVals,
|
|
771
|
+
reparentedVals,
|
|
772
|
+
newTombsIndices.length
|
|
773
|
+
) && !trySpliceInsertedParent(crListReplica, newVals, reparentedVals) && !trySpliceReplacement(
|
|
774
|
+
crListReplica,
|
|
775
|
+
newVals,
|
|
776
|
+
reparentedVals,
|
|
777
|
+
newTombsIndices.length
|
|
778
|
+
)) {
|
|
665
779
|
void rebuildLiveProjection(crListReplica);
|
|
666
780
|
}
|
|
667
781
|
}
|
|
@@ -845,12 +959,13 @@ var CRList = class {
|
|
|
845
959
|
if (change) void dispatchCRListEvent(this.eventTarget, "change", change);
|
|
846
960
|
}
|
|
847
961
|
/**
|
|
848
|
-
* Removes
|
|
962
|
+
* Removes one or more entries starting at an index.
|
|
849
963
|
*
|
|
850
|
-
* @param index - The index to remove.
|
|
964
|
+
* @param index - The first index to remove.
|
|
965
|
+
* @param count - Number of entries to remove. Defaults to `1`.
|
|
851
966
|
*/
|
|
852
|
-
remove(index) {
|
|
853
|
-
const result = __delete(this.state, index, index +
|
|
967
|
+
remove(index, count = 1) {
|
|
968
|
+
const result = __delete(this.state, index, index + count);
|
|
854
969
|
if (!result) return;
|
|
855
970
|
const { delta, change } = result;
|
|
856
971
|
if (delta) void dispatchCRListEvent(this.eventTarget, "delta", delta);
|
|
@@ -866,8 +981,8 @@ var CRList = class {
|
|
|
866
981
|
* @param thisArg - Optional `this` value for the predicate.
|
|
867
982
|
*/
|
|
868
983
|
find(predicate, thisArg) {
|
|
869
|
-
let linkedListEntry = _nullishCoalesce(_optionalChain([this, 'access',
|
|
870
|
-
while (_optionalChain([linkedListEntry, 'optionalAccess',
|
|
984
|
+
let linkedListEntry = _nullishCoalesce(_optionalChain([this, 'access', _88 => _88.state, 'access', _89 => _89.index, 'optionalAccess', _90 => _90.get, 'call', _91 => _91(0)]), () => ( this.state.cursor));
|
|
985
|
+
while (_optionalChain([linkedListEntry, 'optionalAccess', _92 => _92.prev])) linkedListEntry = linkedListEntry.prev;
|
|
871
986
|
let index = 0;
|
|
872
987
|
while (linkedListEntry) {
|
|
873
988
|
if (predicate.call(thisArg, linkedListEntry.value, index, this))
|
|
@@ -977,8 +1092,8 @@ var CRList = class {
|
|
|
977
1092
|
* Iterates over current live values in index order.
|
|
978
1093
|
*/
|
|
979
1094
|
*[Symbol.iterator]() {
|
|
980
|
-
let linkedListEntry = _nullishCoalesce(_optionalChain([this, 'access',
|
|
981
|
-
while (_optionalChain([linkedListEntry, 'optionalAccess',
|
|
1095
|
+
let linkedListEntry = _nullishCoalesce(_optionalChain([this, 'access', _93 => _93.state, 'access', _94 => _94.index, 'optionalAccess', _95 => _95.get, 'call', _96 => _96(0)]), () => ( this.state.cursor));
|
|
1096
|
+
while (_optionalChain([linkedListEntry, 'optionalAccess', _97 => _97.prev])) linkedListEntry = linkedListEntry.prev;
|
|
982
1097
|
while (linkedListEntry) {
|
|
983
1098
|
yield linkedListEntry.value;
|
|
984
1099
|
linkedListEntry = linkedListEntry.next;
|
|
@@ -994,8 +1109,8 @@ var CRList = class {
|
|
|
994
1109
|
* @param thisArg - Optional `this` value for the callback.
|
|
995
1110
|
*/
|
|
996
1111
|
forEach(callback, thisArg) {
|
|
997
|
-
let linkedListEntry = _nullishCoalesce(_optionalChain([this, 'access',
|
|
998
|
-
while (_optionalChain([linkedListEntry, 'optionalAccess',
|
|
1112
|
+
let linkedListEntry = _nullishCoalesce(_optionalChain([this, 'access', _98 => _98.state, 'access', _99 => _99.index, 'optionalAccess', _100 => _100.get, 'call', _101 => _101(0)]), () => ( this.state.cursor));
|
|
1113
|
+
while (_optionalChain([linkedListEntry, 'optionalAccess', _102 => _102.prev])) linkedListEntry = linkedListEntry.prev;
|
|
999
1114
|
let index = 0;
|
|
1000
1115
|
while (linkedListEntry) {
|
|
1001
1116
|
void callback.call(thisArg, linkedListEntry.value, index, this);
|