@arsedizioni/ars-utils 21.1.6 → 21.1.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.
@@ -2476,9 +2476,22 @@ class ClipperSearchResultItemComponent {
2476
2476
  * @returns the chunks info string or undefined
2477
2477
  */
2478
2478
  getChunks() {
2479
- let chunks = this.item().anchors?.sort((a, b) => (a.score ?? 0) - (b.score ?? 0)).slice(0, 5).join('|');
2480
- if (chunks) {
2481
- return "chunks:" + chunks;
2479
+ let anchors = this.item().anchors?.sort((a, b) => (a.score ?? 0) - (b.score ?? 0)).slice(0, 5) ?? [];
2480
+ console.log(anchors.length ?? 0);
2481
+ if (anchors.length > 0) {
2482
+ let chunks = "chunks:";
2483
+ let count = 0;
2484
+ anchors.forEach((anchor, index) => {
2485
+ if (anchor.chunk === undefined)
2486
+ return;
2487
+ if (index > 0) {
2488
+ chunks += "|";
2489
+ }
2490
+ chunks += anchor.chunk;
2491
+ count++;
2492
+ });
2493
+ return count > 0 ? chunks : undefined;
2494
+ console.log(chunks);
2482
2495
  }
2483
2496
  return undefined;
2484
2497
  }