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.d.mts CHANGED
@@ -61,6 +61,11 @@ declare class Language {
61
61
  * Wikitongues classification, Glottolog node name, ISO reference name, autonym, speaker claim.
62
62
  */
63
63
  get labels(): string[];
64
+ /**
65
+ * Check if this language matches the given code by ISO 639-3, ISO 639-1 part1,
66
+ * BCP-47 (exact or prefix), macrolanguage, or Glottocode.
67
+ */
68
+ matchesCode(code: string): boolean;
64
69
  toDict(): LanguageData;
65
70
  }
66
71
  declare class Speaker {
package/dist/index.d.ts CHANGED
@@ -61,6 +61,11 @@ declare class Language {
61
61
  * Wikitongues classification, Glottolog node name, ISO reference name, autonym, speaker claim.
62
62
  */
63
63
  get labels(): string[];
64
+ /**
65
+ * Check if this language matches the given code by ISO 639-3, ISO 639-1 part1,
66
+ * BCP-47 (exact or prefix), macrolanguage, or Glottocode.
67
+ */
68
+ matchesCode(code: string): boolean;
64
69
  toDict(): LanguageData;
65
70
  }
66
71
  declare class Speaker {
package/dist/index.js CHANGED
@@ -10017,6 +10017,21 @@ var Language = class _Language {
10017
10017
  if (this.speakerClaim) out.push(this.speakerClaim);
10018
10018
  return out;
10019
10019
  }
10020
+ /**
10021
+ * Check if this language matches the given code by ISO 639-3, ISO 639-1 part1,
10022
+ * BCP-47 (exact or prefix), macrolanguage, or Glottocode.
10023
+ */
10024
+ matchesCode(code) {
10025
+ const c = code.trim().toLowerCase();
10026
+ if (!c) return false;
10027
+ if (this.iso639_3.toLowerCase() === c) return true;
10028
+ if (this.standards.iso639_3.part1?.toLowerCase() === c) return true;
10029
+ if (this.standards.bcp47.macrolanguage?.toLowerCase() === c) return true;
10030
+ const bcp = this.bcp47.toLowerCase();
10031
+ if (bcp === c || bcp.startsWith(`${c}-`)) return true;
10032
+ if (this.glottocode.toLowerCase() === c) return true;
10033
+ return false;
10034
+ }
10020
10035
  toDict() {
10021
10036
  return {
10022
10037
  standards: {