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.mjs CHANGED
@@ -1317,33 +1317,27 @@ async function generateFurigana(text, bindedFunction) {
1317
1317
  }
1318
1318
  function getValidForms(readings, kanjiForms, wordIsCommon) {
1319
1319
  const kanjiFormRestrictions = /* @__PURE__ */ new Set();
1320
- const validReadings = readings.filter(
1321
- (reading, index) => {
1322
- if (index === 0) return true;
1323
- if (reading.notes === void 0 || !reading.notes.some((note) => notSearchedForms.has(note))) {
1324
- if (reading.kanjiFormRestrictions !== void 0) {
1325
- for (const kfr of reading.kanjiFormRestrictions)
1326
- kanjiFormRestrictions.add(kfr);
1327
- return true;
1328
- }
1329
- if (wordIsCommon === void 0 || reading.commonness !== void 0)
1320
+ const existValidReadings = readings.some(
1321
+ (r) => r.commonness !== void 0 || (r.notes === void 0 || !r.notes.some((note) => notSearchedForms.has(note))) && (r.kanjiFormRestrictions !== void 0 || wordIsCommon === void 0)
1322
+ );
1323
+ const validReadings = readings.filter((r) => {
1324
+ if (!existValidReadings || r.commonness !== void 0 || r.notes === void 0 || !r.notes.some((note) => notSearchedForms.has(note))) {
1325
+ if (r.kanjiFormRestrictions !== void 0) {
1326
+ for (const kfr of r.kanjiFormRestrictions)
1327
+ kanjiFormRestrictions.add(kfr);
1328
+ if (r.notes === void 0 || !r.notes.some((note) => notSearchedForms.has(note)))
1330
1329
  return true;
1331
1330
  }
1332
- return false;
1331
+ if (!existValidReadings || wordIsCommon === void 0 || r.commonness !== void 0)
1332
+ return true;
1333
1333
  }
1334
- );
1335
- const existValidKf = kanjiForms?.some(
1336
- (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))
1334
+ return false;
1335
+ });
1336
+ const existValidKanjiForms = kanjiForms?.some(
1337
+ (kf) => kanjiFormRestrictions.has(kf.form) || kf.commonness !== void 0 || (kf.notes === void 0 || !kf.notes.some((note) => notSearchedForms.has(note))) && wordIsCommon === void 0
1337
1338
  );
1338
1339
  const validKanjiForms = kanjiForms?.filter(
1339
- (kanjiForm, index) => {
1340
- if (index === 0) return true;
1341
- if (existValidKf === true)
1342
- return kanjiForm.notes === void 0 || !kanjiForm.notes.some(
1343
- (note) => notSearchedForms.has(note)
1344
- ) && (wordIsCommon === void 0 || kanjiForm.commonness !== void 0) || kanjiFormRestrictions.has(kanjiForm.form);
1345
- else return true;
1346
- }
1340
+ (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
1347
1341
  );
1348
1342
  return {
1349
1343
  readings: validReadings,