@peassoft/mnr-langs 1.0.0 → 1.1.0

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.ts CHANGED
@@ -10,7 +10,7 @@ type UnionOf<T extends ReadonlyArray<unknown>> = T[number];
10
10
  *
11
11
  * @public
12
12
  */
13
- export declare const supportedLanguges: readonly ["en", "ru"];
13
+ export declare const supportedLanguages: readonly ["en", "ru"];
14
14
  /**
15
15
  * Default language.
16
16
  *
@@ -22,7 +22,7 @@ export declare const defaultLanguage: "en";
22
22
  *
23
23
  * @public
24
24
  */
25
- export type SupportedLanguage = UnionOf<typeof supportedLanguges>;
25
+ export type SupportedLanguage = UnionOf<typeof supportedLanguages>;
26
26
  /**
27
27
  * Get all remaining supported languages except the given one.
28
28
  *
@@ -37,5 +37,13 @@ export declare function getRemainingLanguages(lang: SupportedLanguage): Supporte
37
37
  * @public
38
38
  */
39
39
  export declare function langToPathSegment(lang: SupportedLanguage): '/' | `/${typeof lang}/`;
40
+ /**
41
+ * Validate and type assert a value as a supported language.
42
+ *
43
+ * If the value is not a supported language, returns `null`.
44
+ *
45
+ * @public
46
+ */
47
+ export declare function validateLanguage(value: unknown): SupportedLanguage | null;
40
48
  export {};
41
49
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mBAAmB;AACnB,KAAK,OAAO,CAAC,CAAC,SAAS,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,uBAAwB,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,eAAe,MAAuB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,CAElF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,GAAG,GAAG,GAAG,IAAI,OAAO,IAAI,GAAG,CAGnF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mBAAmB;AACnB,KAAK,OAAO,CAAC,CAAC,SAAS,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,uBAAwB,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,eAAe,MAAwB,CAAC;AAErD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,CAElF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,GAAG,GAAG,GAAG,IAAI,OAAO,IAAI,GAAG,CAGnF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,GAAG,IAAI,CAKzE"}
package/dist/index.js CHANGED
@@ -8,20 +8,20 @@
8
8
  *
9
9
  * @public
10
10
  */
11
- export const supportedLanguges = ['en', 'ru'];
11
+ export const supportedLanguages = ['en', 'ru'];
12
12
  /**
13
13
  * Default language.
14
14
  *
15
15
  * @public
16
16
  */
17
- export const defaultLanguage = supportedLanguges[0];
17
+ export const defaultLanguage = supportedLanguages[0];
18
18
  /**
19
19
  * Get all remaining supported languages except the given one.
20
20
  *
21
21
  * @public
22
22
  */
23
23
  export function getRemainingLanguages(lang) {
24
- return supportedLanguges.filter(l => l !== lang);
24
+ return supportedLanguages.filter(l => l !== lang);
25
25
  }
26
26
  /**
27
27
  * Given a supported language return a path segment for this language.
@@ -35,4 +35,17 @@ export function langToPathSegment(lang) {
35
35
  return '/';
36
36
  return `/${lang}/`;
37
37
  }
38
+ /**
39
+ * Validate and type assert a value as a supported language.
40
+ *
41
+ * If the value is not a supported language, returns `null`.
42
+ *
43
+ * @public
44
+ */
45
+ export function validateLanguage(value) {
46
+ if (typeof value === 'string' && supportedLanguages.includes(value)) {
47
+ return value;
48
+ }
49
+ return null;
50
+ }
38
51
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;AASpD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAuB;IAC3D,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAuB;IACvD,IAAI,IAAI,KAAK,eAAe;QAAE,OAAO,GAAG,CAAC;IACzC,OAAO,IAAI,IAAI,GAAG,CAAC;AACrB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;AASrD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAuB;IAC3D,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAuB;IACvD,IAAI,IAAI,KAAK,eAAe;QAAE,OAAO,GAAG,CAAC;IACzC,OAAO,IAAI,IAAI,GAAG,CAAC;AACrB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAC,KAA0B,CAAC,EAAE,CAAC;QACzF,OAAO,KAA0B,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peassoft/mnr-langs",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "The source of truth for supported UI languages in Memorize'n'Revise",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -16,6 +16,7 @@
16
16
  "@memnrev/eslint-v9-config": "^0.4.0",
17
17
  "@microsoft/api-extractor": "^7.54.0",
18
18
  "@total-typescript/ts-reset": "^0.6.1",
19
+ "asserttt": "^1.0.1",
19
20
  "del-cli": "^7.0.0",
20
21
  "eslint": "^9.8.0",
21
22
  "typescript": "^5.2.0",