rosario 0.6.2 → 0.6.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/lang/index.js +13 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rosario",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "A tiny Holy Rosary prayer engine for web apps",
5
5
  "keywords": [
6
6
  "rosary",
package/src/lang/index.js CHANGED
@@ -1,12 +1,16 @@
1
+ const LANG_LOADERS = {
2
+ en: () => import('./en.js'),
3
+ la: () => import('./la.js'),
4
+ it: () => import('./it.js'),
5
+ }
6
+
1
7
  export async function loadLang (code) {
2
- switch (code) {
3
- case 'en':
4
- return import('./en.js').then(m => m.default)
5
- case 'la':
6
- return import('./la.js').then(m => m.default)
7
- case 'it':
8
- return import('./it.js').then(m => m.default)
9
- default:
10
- throw new Error(`Unsupported language: ${code}`)
8
+ const loader = LANG_LOADERS[code]
9
+
10
+ if (!loader) {
11
+ throw new Error(`Unsupported language: ${code}`)
11
12
  }
13
+
14
+ const module = await loader()
15
+ return module.default
12
16
  }