henkan 2.4.1 → 2.4.3

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/dist/index.cjs.js CHANGED
@@ -1780,44 +1780,34 @@ function createEntryMaps(jmDict, kanjiDic, tanakaExamples, wordDefinitionPairs,
1780
1780
  for (const ex of tanakaExamples)
1781
1781
  for (const part of ex.parts) {
1782
1782
  if (entryParts.has(part.baseForm)) {
1783
- let exList = partExamplesMap.get(
1783
+ const exList = partExamplesMap.get(
1784
1784
  part.baseForm
1785
1785
  );
1786
- if (exList === void 0) {
1787
- exList = [];
1788
- partExamplesMap.set(part.baseForm, exList);
1789
- }
1790
- exList.push(ex);
1786
+ if (exList === void 0) partExamplesMap.set(part.baseForm, [ex]);
1787
+ else exList.push(ex);
1791
1788
  }
1792
1789
  if (part.reading !== void 0 && entryParts.has(part.reading)) {
1793
- let exList = partExamplesMap.get(
1790
+ const exList = partExamplesMap.get(
1794
1791
  part.reading
1795
1792
  );
1796
- if (exList === void 0) {
1797
- exList = [];
1798
- partExamplesMap.set(part.reading, exList);
1799
- }
1800
- exList.push(ex);
1793
+ if (exList === void 0) partExamplesMap.set(part.reading, [ex]);
1794
+ else exList.push(ex);
1801
1795
  }
1802
1796
  if (part.inflectedForm !== void 0 && entryParts.has(part.inflectedForm)) {
1803
- let exList = partExamplesMap.get(
1797
+ const exList = partExamplesMap.get(
1804
1798
  part.inflectedForm
1805
1799
  );
1806
- if (exList === void 0) {
1807
- exList = [];
1808
- partExamplesMap.set(part.inflectedForm, exList);
1809
- }
1810
- exList.push(ex);
1800
+ if (exList === void 0)
1801
+ partExamplesMap.set(part.inflectedForm, [ex]);
1802
+ else exList.push(ex);
1811
1803
  }
1812
1804
  if (part.referenceID !== void 0 && entryParts.has(part.referenceID)) {
1813
- let exList = partExamplesMap.get(
1805
+ const exList = partExamplesMap.get(
1814
1806
  part.referenceID
1815
1807
  );
1816
- if (exList === void 0) {
1817
- exList = [];
1818
- partExamplesMap.set(part.referenceID, exList);
1819
- }
1820
- exList.push(ex);
1808
+ if (exList === void 0)
1809
+ partExamplesMap.set(part.referenceID, [ex]);
1810
+ else exList.push(ex);
1821
1811
  }
1822
1812
  }
1823
1813
  for (const word of jmDict) {
@@ -2603,14 +2593,16 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
2603
2593
  const readingMatchingKanjiFormExamples = [];
2604
2594
  const readingExamples = [];
2605
2595
  const readingMatchingKanjiForms = /* @__PURE__ */ new Set();
2596
+ const seenPhrases = /* @__PURE__ */ new Set();
2606
2597
  for (const example of exampleList)
2607
2598
  for (let i = 0; i < example.parts.length; i++) {
2599
+ if (seenPhrases.has(example.phrase)) break;
2608
2600
  const part = example.parts[i];
2609
2601
  const readingAsReadingMatch = part.reading !== void 0 && readings.has(part.reading);
2610
2602
  const readingAsInflectedFormMatch = part.inflectedForm !== void 0 && readings.has(part.inflectedForm);
2611
2603
  const referenceIDMatch = part.referenceID === dictWord.id;
2612
- if (kanjiForms !== void 0 && kanjiForms.has(part.baseForm) || referenceIDMatch) {
2613
- if (readingAsReadingMatch || readingAsInflectedFormMatch) {
2604
+ if (kanjiForms !== void 0 && kanjiForms.has(part.baseForm)) {
2605
+ if (readingAsReadingMatch || readingAsInflectedFormMatch || referenceIDMatch) {
2614
2606
  readingMatchingKanjiFormExamples.push({
2615
2607
  ex: example,
2616
2608
  partIndex: i
@@ -2622,11 +2614,13 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
2622
2614
  partIndex: i,
2623
2615
  form: part.baseForm
2624
2616
  });
2617
+ seenPhrases.add(example.phrase);
2625
2618
  break;
2626
2619
  }
2627
2620
  const readingAsBaseFormMatch = readings.has(part.baseForm);
2628
- if (readingAsBaseFormMatch && kanjiForms === void 0) {
2621
+ if ((readingAsBaseFormMatch || referenceIDMatch) && kanjiForms === void 0) {
2629
2622
  readingExamples.push({ ex: example, partIndex: i });
2623
+ seenPhrases.add(example.phrase);
2630
2624
  break;
2631
2625
  }
2632
2626
  }
@@ -2637,13 +2631,12 @@ function getWord(searchedWord, dict, kanjiDic, examples, definitions, noteTypeNa
2637
2631
  const includeKanjiFormExamples = word.kanjiForms !== void 0;
2638
2632
  let wordExamples = [
2639
2633
  ...includeKanjiFormExamples ? [...readingMatchingKanjiFormExamples, ...kanjiFormExamples] : readingExamples
2640
- ];
2641
- wordExamples.sort(
2634
+ ].toSorted(
2642
2635
  (a, b) => a.ex.phrase.length - b.ex.phrase.length
2643
2636
  );
2644
2637
  readingMatchingKanjiForms.clear();
2638
+ seenPhrases.clear();
2645
2639
  const glossSpecificExamples = [];
2646
- const seenPhrases = /* @__PURE__ */ new Set();
2647
2640
  for (let i = 0; i < word.translations.length; i++)
2648
2641
  outer: for (const example of wordExamples) {
2649
2642
  if (seenPhrases.has(example.ex.phrase)) continue;