rosario 0.1.2 → 0.2.1

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/README.md CHANGED
@@ -11,11 +11,15 @@ npm install rosario
11
11
  ## Usage
12
12
 
13
13
  ```bash
14
- import rosario from "rosario";
14
+ import rosario from 'rosario';
15
15
 
16
- const r = rosario({ mystery: "joyful" });
16
+ const r = await rosario({
17
+ mystery: 'joyful',
18
+ lang: 'en',
19
+ });
17
20
 
18
21
  console.log(r.current());
19
22
 
20
23
  r.next();
24
+ console.log(r.current());
21
25
  ```
package/index.d.ts CHANGED
@@ -6,16 +6,24 @@ export type Mystery =
6
6
 
7
7
  export interface RosarioOptions {
8
8
  mystery?: Mystery
9
+ lang?: string
10
+ }
11
+
12
+ export interface RosarioCurrent {
13
+ prayer: string
14
+ text: string
9
15
  }
10
16
 
11
17
  export interface RosarioSession {
12
18
  next(): void
13
19
 
14
- current(): string
20
+ current(): RosarioCurrent
15
21
 
16
22
  done(): boolean
23
+
24
+ reset(): void
17
25
  }
18
26
 
19
27
  export default function rosario(
20
28
  options?: RosarioOptions
21
- ): RosarioSession
29
+ ): Promise<RosarioSession>
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { MYSTERIES } from './src/mysteries.js'
2
- import { PRAYERS } from './src/prayers.js'
2
+ import { loadLang } from './src/lang/index.js'
3
3
 
4
4
  const DECADE = [
5
5
  'ourFather',
@@ -23,29 +23,41 @@ function buildOrder (mystery) {
23
23
  ]
24
24
  }
25
25
 
26
- export default function rosario ({ mystery = 'joyful' } = {}) {
26
+ export default async function rosario ({
27
+ mystery = 'joyful',
28
+ lang = 'en',
29
+ } = {}) {
30
+ const locale =
31
+ typeof lang === 'string'
32
+ ? await loadLang(lang)
33
+ : lang
34
+
35
+ if (!locale || !locale.prayers) {
36
+ throw new Error('Invalid language object: missing `prayers`')
37
+ }
38
+
27
39
  const order = buildOrder(mystery)
28
40
  let index = 0
29
41
 
30
42
  return {
31
- next() {
43
+ next () {
32
44
  if (index < order.length - 1) index++
33
45
  },
34
46
 
35
- current() {
47
+ current () {
36
48
  const key = order[index]
37
49
  return {
38
50
  prayer: key,
39
- text: PRAYERS[key]
51
+ text: locale.prayers[key],
40
52
  }
41
53
  },
42
54
 
43
- done() {
55
+ done () {
44
56
  return index >= order.length - 1
45
57
  },
46
58
 
47
- reset() {
59
+ reset () {
48
60
  index = 0
49
- }
61
+ },
50
62
  }
51
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rosario",
3
- "version": "0.1.2",
3
+ "version": "0.2.1",
4
4
  "description": "A tiny Catholic rosary prayer engine for web apps",
5
5
  "keywords": [
6
6
  "rosary",
package/src/lang/en.js ADDED
@@ -0,0 +1,35 @@
1
+ export default {
2
+ prayers: {
3
+ apostlesCreed: 'I believe in God, the Father Almighty, Creator of Heaven and earth; and in Jesus Christ, His only Son, Our Lord, Who was conceived by the Holy Ghost, born of the Virgin Mary, suffered under Pontius Pilate, was crucified; died, and was buried. He descended into Hell; the third day He arose again from the dead; He ascended into Heaven, sitteth at the right hand of God, the Father Almighty; from thence He shall come to judge the living and the dead. I believe in the Holy Spirit, the holy Catholic Church, the communion of saints, the forgiveness of sins, the resurrection of the body, and the life everlasting. Amen.',
4
+ ourFather: 'Our Father, Who art in heaven, hallowed be Thy name; Thy kingdom come; Thy will be done on earth as it is in heaven. Give us this day our daily bread; and forgive us our trespasses as we forgive those who trespass against us; and lead us not into temptation, but deliver us from evil, Amen.',
5
+ hailMary: 'Hail Mary, full of grace. The Lord is with thee. Blessed art thou amongst women, and blessed is the fruit of thy womb, Jesus. Holy Mary, Mother of God, pray for us sinners, now and at the hour of our death, Amen.',
6
+ gloryBe: 'Glory be to the Father, and to the Son, and to the Holy Spirit. As it was in the beginning, is now, and ever shall be, world without end. Amen.',
7
+ fatimaPrayer: 'O my Jesus, forgive us our sins, save us from the fires of hell, lead all souls to Heaven, especially those in most need of Thy mercy.',
8
+ },
9
+
10
+ mysteries: {
11
+ annunciation: 'The Annunciation',
12
+ visitation: 'The Visitation',
13
+ nativity: 'The Birth of Jesus',
14
+ presentation: 'The Presentation',
15
+ findingInTemple: 'Finding the Child Jesus in the Temple',
16
+
17
+ baptism: 'Baptism of Jesus',
18
+ weddingAtCana: 'Wedding at Cana',
19
+ proclaimingKingdom: 'Proclaiming the Kingdom',
20
+ transfiguration: 'Transfiguration',
21
+ institutionEucharist: 'Institution of the Eucharist',
22
+
23
+ agonyInGarden: 'The Agony in the Garden',
24
+ scourgingAtPillar: 'The Scourging at the Pillar',
25
+ crowningWithThorns: 'Crowning With Thorns',
26
+ carryingCross: 'Carrying of the Cross',
27
+ crucifixion: 'The Crucifixion',
28
+
29
+ resurrection: 'The Resurrection',
30
+ ascension: 'The Ascension',
31
+ descentHolySpirit: 'Descent of the Holy Spirit',
32
+ assumption: 'The Assumption',
33
+ coronation: 'The Coronation'
34
+ },
35
+ }
@@ -0,0 +1,8 @@
1
+ export async function loadLang (code) {
2
+ switch (code) {
3
+ case 'en':
4
+ return import('./en.js').then(m => m.default)
5
+ default:
6
+ throw new Error(`Unsupported language: ${code}`)
7
+ }
8
+ }
package/src/mysteries.js CHANGED
@@ -1,30 +1,30 @@
1
1
  export const MYSTERIES = {
2
2
  joyful: [
3
- 'The Annunciation',
4
- 'The Visitation',
5
- 'The Birth of Jesus',
6
- 'The Presentation',
7
- 'Finding the Child Jesus in the Temple'
3
+ 'annunciation',
4
+ 'visitation',
5
+ 'nativity',
6
+ 'presentation',
7
+ 'findingInTemple',
8
8
  ],
9
9
  luminous: [
10
- 'Baptism of Jesus',
11
- 'Wedding at Cana',
12
- 'Proclaiming the Kingdom',
13
- 'Transfiguration',
14
- 'Institution of the Eucharist'
10
+ 'baptism',
11
+ 'weddingAtCana',
12
+ 'proclaimingKingdom',
13
+ 'transfiguration',
14
+ 'institutionEucharist',
15
15
  ],
16
16
  sorrowful: [
17
- 'The Agony in the Garden',
18
- 'The Scourging at the Pillar',
19
- 'Crowning With Thorns',
20
- 'Carrying of the Cross',
21
- 'The Crucifixion',
17
+ 'agonyInGarden',
18
+ 'scourgingAtPillar',
19
+ 'crowningWithThorns',
20
+ 'carryingCross',
21
+ 'crucifixion',
22
22
  ],
23
23
  glorious: [
24
- 'The Resurrection',
25
- 'The Ascension',
26
- 'Descent of the Holy Spirit',
27
- 'The Assumption',
28
- 'The Coronation',
24
+ 'resurrection',
25
+ 'ascension',
26
+ 'descentHolySpirit',
27
+ 'assumption',
28
+ 'coronation',
29
29
  ],
30
30
  }
package/src/prayers.js DELETED
@@ -1,7 +0,0 @@
1
- export const PRAYERS = {
2
- apostlesCreed: 'I believe in God, the Father Almighty, Creator of Heaven and earth; and in Jesus Christ, His only Son, Our Lord, Who was conceived by the Holy Ghost, born of the Virgin Mary, suffered under Pontius Pilate, was crucified; died, and was buried. He descended into Hell; the third day He arose again from the dead; He ascended into Heaven, sitteth at the right hand of God, the Father Almighty; from thence He shall come to judge the living and the dead. I believe in the Holy Spirit, the holy Catholic Church, the communion of saints, the forgiveness of sins, the resurrection of the body, and the life everlasting. Amen.',
3
- ourFather: 'Our Father, Who art in heaven, hallowed be Thy name; Thy kingdom come; Thy will be done on earth as it is in heaven. Give us this day our daily bread; and forgive us our trespasses as we forgive those who trespass against us; and lead us not into temptation, but deliver us from evil, Amen.',
4
- hailMary: 'Hail Mary, full of grace. The Lord is with thee. Blessed art thou amongst women, and blessed is the fruit of thy womb, Jesus. Holy Mary, Mother of God, pray for us sinners, now and at the hour of our death, Amen.',
5
- gloryBe: 'Glory be to the Father, and to the Son, and to the Holy Spirit. As it was in the beginning, is now, and ever shall be, world without end. Amen.',
6
- fatimaPrayer: 'O my Jesus, forgive us our sins, save us from the fires of hell, lead all souls to Heaven, especially those in most need of Thy mercy.',
7
- }