wikitongues-db 0.2.3 → 0.2.4

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
@@ -10015,6 +10015,21 @@ var Language = class _Language {
10015
10015
  if (this.speakerClaim) out.push(this.speakerClaim);
10016
10016
  return out;
10017
10017
  }
10018
+ /**
10019
+ * Check if this language matches the given code by ISO 639-3, ISO 639-1 part1,
10020
+ * BCP-47 (exact or prefix), macrolanguage, or Glottocode.
10021
+ */
10022
+ matchesCode(code) {
10023
+ const c = code.trim().toLowerCase();
10024
+ if (!c) return false;
10025
+ if (this.iso639_3.toLowerCase() === c) return true;
10026
+ if (this.standards.iso639_3.part1?.toLowerCase() === c) return true;
10027
+ if (this.standards.bcp47.macrolanguage?.toLowerCase() === c) return true;
10028
+ const bcp = this.bcp47.toLowerCase();
10029
+ if (bcp === c || bcp.startsWith(`${c}-`)) return true;
10030
+ if (this.glottocode.toLowerCase() === c) return true;
10031
+ return false;
10032
+ }
10018
10033
  toDict() {
10019
10034
  return {
10020
10035
  standards: {