henkan 3.0.1 → 3.0.2

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
@@ -1383,33 +1383,27 @@ async function generateFurigana(text, bindedFunction) {
1383
1383
  }
1384
1384
  function getValidForms(readings, kanjiForms, wordIsCommon) {
1385
1385
  const kanjiFormRestrictions = /* @__PURE__ */ new Set();
1386
- const validReadings = readings.filter(
1387
- (reading, index) => {
1388
- if (index === 0) return true;
1389
- if (reading.notes === void 0 || !reading.notes.some((note) => notSearchedForms.has(note))) {
1390
- if (reading.kanjiFormRestrictions !== void 0) {
1391
- for (const kfr of reading.kanjiFormRestrictions)
1392
- kanjiFormRestrictions.add(kfr);
1393
- return true;
1394
- }
1395
- if (wordIsCommon === void 0 || reading.commonness !== void 0)
1386
+ const existValidReadings = readings.some(
1387
+ (r) => r.commonness !== void 0 || (r.notes === void 0 || !r.notes.some((note) => notSearchedForms.has(note))) && (r.kanjiFormRestrictions !== void 0 || wordIsCommon === void 0)
1388
+ );
1389
+ const validReadings = readings.filter((r) => {
1390
+ if (!existValidReadings || r.commonness !== void 0 || r.notes === void 0 || !r.notes.some((note) => notSearchedForms.has(note))) {
1391
+ if (r.kanjiFormRestrictions !== void 0) {
1392
+ for (const kfr of r.kanjiFormRestrictions)
1393
+ kanjiFormRestrictions.add(kfr);
1394
+ if (r.notes === void 0 || !r.notes.some((note) => notSearchedForms.has(note)))
1396
1395
  return true;
1397
1396
  }
1398
- return false;
1397
+ if (!existValidReadings || wordIsCommon === void 0 || r.commonness !== void 0)
1398
+ return true;
1399
1399
  }
1400
- );
1401
- const existValidKf = kanjiForms?.some(
1402
- (kf, index) => index !== 0 && (kf.notes === void 0 || !kf.notes.some((note) => notSearchedForms.has(note)) && (wordIsCommon === void 0 || kf.commonness !== void 0) || kanjiFormRestrictions.has(kf.form))
1400
+ return false;
1401
+ });
1402
+ const existValidKanjiForms = kanjiForms?.some(
1403
+ (kf) => kanjiFormRestrictions.has(kf.form) || kf.commonness !== void 0 || (kf.notes === void 0 || !kf.notes.some((note) => notSearchedForms.has(note))) && wordIsCommon === void 0
1403
1404
  );
1404
1405
  const validKanjiForms = kanjiForms?.filter(
1405
- (kanjiForm, index) => {
1406
- if (index === 0) return true;
1407
- if (existValidKf === true)
1408
- return kanjiForm.notes === void 0 || !kanjiForm.notes.some(
1409
- (note) => notSearchedForms.has(note)
1410
- ) && (wordIsCommon === void 0 || kanjiForm.commonness !== void 0) || kanjiFormRestrictions.has(kanjiForm.form);
1411
- else return true;
1412
- }
1406
+ (kf) => existValidKanjiForms === false || kanjiFormRestrictions.has(kf.form) || kf.commonness !== void 0 || (kf.notes === void 0 || !kf.notes.some((note) => notSearchedForms.has(note))) && wordIsCommon === void 0
1413
1407
  );
1414
1408
  return {
1415
1409
  readings: validReadings,