@joewalker/scripture-ref 0.4.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/CHANGELOG.md +24 -0
- package/LICENSE +202 -0
- package/README.md +102 -0
- package/dist/book/books.d.ts +45 -0
- package/dist/book/books.js +196 -0
- package/dist/book/books.js.map +1 -0
- package/dist/book/esv.json +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/passage/bible-info.d.ts +64 -0
- package/dist/passage/bible-info.js +874 -0
- package/dist/passage/bible-info.js.map +1 -0
- package/dist/passage/passage-tally.d.ts +25 -0
- package/dist/passage/passage-tally.js +44 -0
- package/dist/passage/passage-tally.js.map +1 -0
- package/dist/passage/passage.d.ts +44 -0
- package/dist/passage/passage.js +120 -0
- package/dist/passage/passage.js.map +1 -0
- package/dist/passage/verse-range.d.ts +74 -0
- package/dist/passage/verse-range.js +213 -0
- package/dist/passage/verse-range.js.map +1 -0
- package/dist/passage/verse.d.ts +104 -0
- package/dist/passage/verse.js +295 -0
- package/dist/passage/verse.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
/** Constant for the number of books in the Bible */
|
|
2
|
+
const BOOKS_IN_BIBLE = 66;
|
|
3
|
+
/** Constant for the number of chapters in the Bible */
|
|
4
|
+
const CHAPTERS_IN_BIBLE = 1189;
|
|
5
|
+
/** Constant for the number of verses in the Bible */
|
|
6
|
+
const VERSES_IN_BIBLE = 31102;
|
|
7
|
+
const LONG_NAMES = [
|
|
8
|
+
'Genesis',
|
|
9
|
+
'Exodus',
|
|
10
|
+
'Leviticus',
|
|
11
|
+
'Numbers',
|
|
12
|
+
'Deuteronomy',
|
|
13
|
+
'Joshua',
|
|
14
|
+
'Judges',
|
|
15
|
+
'Ruth',
|
|
16
|
+
'1Samuel',
|
|
17
|
+
'2Samuel',
|
|
18
|
+
'1Kings',
|
|
19
|
+
'2Kings',
|
|
20
|
+
'1Chronicles',
|
|
21
|
+
'2Chronicles',
|
|
22
|
+
'Ezra',
|
|
23
|
+
'Nehemiah',
|
|
24
|
+
'Esther',
|
|
25
|
+
'Job',
|
|
26
|
+
'Psalms',
|
|
27
|
+
'Proverbs',
|
|
28
|
+
'Ecclesiastes',
|
|
29
|
+
'Song of Solomon',
|
|
30
|
+
'Isaiah',
|
|
31
|
+
'Jeremiah',
|
|
32
|
+
'Lamentations',
|
|
33
|
+
'Ezekiel',
|
|
34
|
+
'Daniel',
|
|
35
|
+
'Hosea',
|
|
36
|
+
'Joel',
|
|
37
|
+
'Amos',
|
|
38
|
+
'Obadiah',
|
|
39
|
+
'Jonah',
|
|
40
|
+
'Micah',
|
|
41
|
+
'Nahum',
|
|
42
|
+
'Habakkuk',
|
|
43
|
+
'Zephaniah',
|
|
44
|
+
'Haggai',
|
|
45
|
+
'Zechariah',
|
|
46
|
+
'Malachi',
|
|
47
|
+
'Matthew',
|
|
48
|
+
'Mark',
|
|
49
|
+
'Luke',
|
|
50
|
+
'John',
|
|
51
|
+
'Acts',
|
|
52
|
+
'Romans',
|
|
53
|
+
'1Corinthians',
|
|
54
|
+
'2Corinthians',
|
|
55
|
+
'Galatians',
|
|
56
|
+
'Ephesians',
|
|
57
|
+
'Philippians',
|
|
58
|
+
'Colossians',
|
|
59
|
+
'1Thessalonians',
|
|
60
|
+
'2Thessalonians',
|
|
61
|
+
'1Timothy',
|
|
62
|
+
'2Timothy',
|
|
63
|
+
'Titus',
|
|
64
|
+
'Philemon',
|
|
65
|
+
'Hebrews',
|
|
66
|
+
'James',
|
|
67
|
+
'1Peter',
|
|
68
|
+
'2Peter',
|
|
69
|
+
'1John',
|
|
70
|
+
'2John',
|
|
71
|
+
'3John',
|
|
72
|
+
'Jude',
|
|
73
|
+
'Revelation',
|
|
74
|
+
];
|
|
75
|
+
const SHORT_NAMES = [
|
|
76
|
+
'Gen',
|
|
77
|
+
'Exo',
|
|
78
|
+
'Lev',
|
|
79
|
+
'Num',
|
|
80
|
+
'Deu',
|
|
81
|
+
'Jos',
|
|
82
|
+
'Judg',
|
|
83
|
+
'Rut',
|
|
84
|
+
'1Sa',
|
|
85
|
+
'2Sa',
|
|
86
|
+
'1Ki',
|
|
87
|
+
'2Ki',
|
|
88
|
+
'1Ch',
|
|
89
|
+
'2Ch',
|
|
90
|
+
'Ezr',
|
|
91
|
+
'Neh',
|
|
92
|
+
'Est',
|
|
93
|
+
'Job',
|
|
94
|
+
'Psa',
|
|
95
|
+
'Pro',
|
|
96
|
+
'Ecc',
|
|
97
|
+
'Son',
|
|
98
|
+
'Isa',
|
|
99
|
+
'Jer',
|
|
100
|
+
'Lam',
|
|
101
|
+
'Eze',
|
|
102
|
+
'Dan',
|
|
103
|
+
'Hos',
|
|
104
|
+
'Joe',
|
|
105
|
+
'Amo',
|
|
106
|
+
'Oba',
|
|
107
|
+
'Jon',
|
|
108
|
+
'Mic',
|
|
109
|
+
'Nah',
|
|
110
|
+
'Hab',
|
|
111
|
+
'Zep',
|
|
112
|
+
'Hag',
|
|
113
|
+
'Zec',
|
|
114
|
+
'Mal',
|
|
115
|
+
'Mat',
|
|
116
|
+
'Mar',
|
|
117
|
+
'Luk',
|
|
118
|
+
'Joh',
|
|
119
|
+
'Act',
|
|
120
|
+
'Rom',
|
|
121
|
+
'1Co',
|
|
122
|
+
'2Co',
|
|
123
|
+
'Gal',
|
|
124
|
+
'Eph',
|
|
125
|
+
'Phili',
|
|
126
|
+
'Col',
|
|
127
|
+
'1Th',
|
|
128
|
+
'2Th',
|
|
129
|
+
'1Ti',
|
|
130
|
+
'2Ti',
|
|
131
|
+
'Tit',
|
|
132
|
+
'Phile',
|
|
133
|
+
'Heb',
|
|
134
|
+
'Jam',
|
|
135
|
+
'1Pe',
|
|
136
|
+
'2Pe',
|
|
137
|
+
'1Jo',
|
|
138
|
+
'2Jo',
|
|
139
|
+
'3Jo',
|
|
140
|
+
'Jude',
|
|
141
|
+
'Rev',
|
|
142
|
+
];
|
|
143
|
+
/**
|
|
144
|
+
* Lookup table for {@link findBookNumber}
|
|
145
|
+
*/
|
|
146
|
+
const books = {
|
|
147
|
+
'1': {
|
|
148
|
+
'1kings': 11,
|
|
149
|
+
'1ki': 11,
|
|
150
|
+
'1chronicles': 13,
|
|
151
|
+
'1ch': 13,
|
|
152
|
+
'1corinthians': 46,
|
|
153
|
+
'1co': 46,
|
|
154
|
+
'1john': 62,
|
|
155
|
+
'1jo': 62,
|
|
156
|
+
'1peter': 60,
|
|
157
|
+
'1pe': 60,
|
|
158
|
+
'1samuel': 9,
|
|
159
|
+
'1sa': 9,
|
|
160
|
+
'1thessalonians': 52,
|
|
161
|
+
'1th': 52,
|
|
162
|
+
'1timothy': 54,
|
|
163
|
+
'1ti': 54,
|
|
164
|
+
},
|
|
165
|
+
'2': {
|
|
166
|
+
'2kings': 12,
|
|
167
|
+
'2ki': 12,
|
|
168
|
+
'2chronicles': 14,
|
|
169
|
+
'2ch': 14,
|
|
170
|
+
'2corinthians': 47,
|
|
171
|
+
'2co': 47,
|
|
172
|
+
'2john': 63,
|
|
173
|
+
'2jo': 63,
|
|
174
|
+
'2peter': 61,
|
|
175
|
+
'2pe': 61,
|
|
176
|
+
'2samuel': 10,
|
|
177
|
+
'2sa': 10,
|
|
178
|
+
'2thessalonians': 53,
|
|
179
|
+
'2th': 53,
|
|
180
|
+
'2timothy': 55,
|
|
181
|
+
'2ti': 55,
|
|
182
|
+
},
|
|
183
|
+
'3': {
|
|
184
|
+
'3john': 64,
|
|
185
|
+
'3jo': 64,
|
|
186
|
+
},
|
|
187
|
+
a: {
|
|
188
|
+
acts: 44,
|
|
189
|
+
act: 44,
|
|
190
|
+
amos: 30,
|
|
191
|
+
amo: 30,
|
|
192
|
+
am: 30,
|
|
193
|
+
},
|
|
194
|
+
b: {},
|
|
195
|
+
c: {
|
|
196
|
+
colossians: 51,
|
|
197
|
+
col: 51,
|
|
198
|
+
},
|
|
199
|
+
d: {
|
|
200
|
+
deuteronomy: 5,
|
|
201
|
+
deu: 5,
|
|
202
|
+
daniel: 27,
|
|
203
|
+
dan: 27,
|
|
204
|
+
},
|
|
205
|
+
e: {
|
|
206
|
+
exodus: 2,
|
|
207
|
+
exo: 2,
|
|
208
|
+
ezra: 15,
|
|
209
|
+
ezr: 15,
|
|
210
|
+
esther: 17,
|
|
211
|
+
est: 17,
|
|
212
|
+
ecclesiastes: 21,
|
|
213
|
+
ecc: 21,
|
|
214
|
+
ezekiel: 26,
|
|
215
|
+
eze: 26,
|
|
216
|
+
ephesians: 49,
|
|
217
|
+
eph: 49,
|
|
218
|
+
},
|
|
219
|
+
f: {},
|
|
220
|
+
g: {
|
|
221
|
+
genesis: 1,
|
|
222
|
+
gen: 1,
|
|
223
|
+
galatians: 48,
|
|
224
|
+
gal: 48,
|
|
225
|
+
},
|
|
226
|
+
h: {
|
|
227
|
+
hosea: 28,
|
|
228
|
+
hos: 28,
|
|
229
|
+
habakkuk: 35,
|
|
230
|
+
hab: 35,
|
|
231
|
+
haggai: 37,
|
|
232
|
+
hag: 37,
|
|
233
|
+
hebrews: 58,
|
|
234
|
+
heb: 58,
|
|
235
|
+
},
|
|
236
|
+
i: {
|
|
237
|
+
isaiah: 23,
|
|
238
|
+
isa: 23,
|
|
239
|
+
},
|
|
240
|
+
j: {
|
|
241
|
+
joshua: 6,
|
|
242
|
+
jos: 6,
|
|
243
|
+
judges: 7,
|
|
244
|
+
judg: 7,
|
|
245
|
+
job: 18,
|
|
246
|
+
jeremiah: 24,
|
|
247
|
+
jer: 24,
|
|
248
|
+
joel: 29,
|
|
249
|
+
joe: 29,
|
|
250
|
+
jonah: 32,
|
|
251
|
+
jon: 32,
|
|
252
|
+
john: 43,
|
|
253
|
+
joh: 43,
|
|
254
|
+
james: 59,
|
|
255
|
+
jam: 59,
|
|
256
|
+
jude: 65,
|
|
257
|
+
jud: 65,
|
|
258
|
+
},
|
|
259
|
+
k: {},
|
|
260
|
+
l: {
|
|
261
|
+
leviticus: 3,
|
|
262
|
+
lev: 3,
|
|
263
|
+
lamentations: 25,
|
|
264
|
+
lam: 25,
|
|
265
|
+
luke: 42,
|
|
266
|
+
luk: 42,
|
|
267
|
+
},
|
|
268
|
+
m: {
|
|
269
|
+
micah: 33,
|
|
270
|
+
mic: 33,
|
|
271
|
+
malachi: 39,
|
|
272
|
+
mal: 39,
|
|
273
|
+
matthew: 40,
|
|
274
|
+
mat: 40,
|
|
275
|
+
mark: 41,
|
|
276
|
+
mar: 41,
|
|
277
|
+
},
|
|
278
|
+
n: {
|
|
279
|
+
numbers: 4,
|
|
280
|
+
num: 4,
|
|
281
|
+
nehemiah: 16,
|
|
282
|
+
neh: 16,
|
|
283
|
+
nahum: 34,
|
|
284
|
+
nah: 34,
|
|
285
|
+
},
|
|
286
|
+
o: {
|
|
287
|
+
obadiah: 31,
|
|
288
|
+
oba: 31,
|
|
289
|
+
},
|
|
290
|
+
p: {
|
|
291
|
+
psalms: 19,
|
|
292
|
+
psa: 19,
|
|
293
|
+
proverbs: 20,
|
|
294
|
+
pro: 20,
|
|
295
|
+
philippians: 50,
|
|
296
|
+
phili: 50,
|
|
297
|
+
philemon: 57,
|
|
298
|
+
phile: 57,
|
|
299
|
+
},
|
|
300
|
+
q: {},
|
|
301
|
+
r: {
|
|
302
|
+
ruth: 8,
|
|
303
|
+
rut: 8,
|
|
304
|
+
romans: 45,
|
|
305
|
+
rom: 45,
|
|
306
|
+
revelation: 66,
|
|
307
|
+
rev: 66,
|
|
308
|
+
},
|
|
309
|
+
s: {
|
|
310
|
+
songofsolomon: 22,
|
|
311
|
+
son: 22,
|
|
312
|
+
song: 22,
|
|
313
|
+
ss: 22,
|
|
314
|
+
},
|
|
315
|
+
t: {
|
|
316
|
+
titus: 56,
|
|
317
|
+
tit: 56,
|
|
318
|
+
},
|
|
319
|
+
u: {},
|
|
320
|
+
v: {},
|
|
321
|
+
w: {},
|
|
322
|
+
x: {},
|
|
323
|
+
y: {},
|
|
324
|
+
z: {
|
|
325
|
+
zephaniah: 36,
|
|
326
|
+
zep: 36,
|
|
327
|
+
zechariah: 38,
|
|
328
|
+
zec: 38,
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* Find the (1-based) book number for a given string.
|
|
333
|
+
* e.g.:
|
|
334
|
+
* - findBookNumber('genesis') === 1
|
|
335
|
+
* - findBookNumber('gen') === 1
|
|
336
|
+
* - findBookNumber('g') === undefined
|
|
337
|
+
*/
|
|
338
|
+
export function findBookNumber(name) {
|
|
339
|
+
if (name === null || name === undefined) {
|
|
340
|
+
return undefined;
|
|
341
|
+
}
|
|
342
|
+
const lookupName = name.replace(/\s/g, '').toLowerCase();
|
|
343
|
+
if (lookupName.length < 2) {
|
|
344
|
+
return undefined;
|
|
345
|
+
}
|
|
346
|
+
const first = lookupName[0];
|
|
347
|
+
const section = books[first];
|
|
348
|
+
if (section == null) {
|
|
349
|
+
return undefined;
|
|
350
|
+
}
|
|
351
|
+
for (const [bookName, number] of Object.entries(section)) {
|
|
352
|
+
if (lookupName === bookName) {
|
|
353
|
+
return number;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return undefined;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Constant for the number of chapters in each book
|
|
360
|
+
* @see chaptersInBook
|
|
361
|
+
*/
|
|
362
|
+
const CHAPTERS_IN_BOOK = [
|
|
363
|
+
50, 40, 27, 36, 34, 24, 21, 4, 31, 24, 22, 25, 29, 36, 10, 13, 10, 42, 150,
|
|
364
|
+
31, 12, 8, 66, 52, 5, 48, 12, 14, 3, 9, 1, 4, 7, 3, 3, 3, 2, 14, 4, 28, 16,
|
|
365
|
+
24, 21, 28, 16, 16, 13, 6, 6, 4, 4, 5, 3, 6, 4, 3, 1, 13, 5, 5, 3, 5, 1, 1, 1,
|
|
366
|
+
22,
|
|
367
|
+
];
|
|
368
|
+
/**
|
|
369
|
+
* Constant for the number of verses in each chapter
|
|
370
|
+
* @see versesInChapter
|
|
371
|
+
*/
|
|
372
|
+
const VERSES_IN_CHAPTER = [
|
|
373
|
+
[
|
|
374
|
+
31, 25, 24, 26, 32, 22, 24, 22, 29, 32, 32, 20, 18, 24, 21, 16, 27, 33, 38,
|
|
375
|
+
18, 34, 24, 20, 67, 34, 35, 46, 22, 35, 43, 55, 32, 20, 31, 29, 43, 36, 30,
|
|
376
|
+
23, 23, 57, 38, 34, 34, 28, 34, 31, 22, 33, 26,
|
|
377
|
+
],
|
|
378
|
+
[
|
|
379
|
+
22, 25, 22, 31, 23, 30, 25, 32, 35, 29, 10, 51, 22, 31, 27, 36, 16, 27, 25,
|
|
380
|
+
26, 36, 31, 33, 18, 40, 37, 21, 43, 46, 38, 18, 35, 23, 35, 35, 38, 29, 31,
|
|
381
|
+
43, 38,
|
|
382
|
+
],
|
|
383
|
+
[
|
|
384
|
+
17, 16, 17, 35, 19, 30, 38, 36, 24, 20, 47, 8, 59, 57, 33, 34, 16, 30, 37,
|
|
385
|
+
27, 24, 33, 44, 23, 55, 46, 34,
|
|
386
|
+
],
|
|
387
|
+
[
|
|
388
|
+
54, 34, 51, 49, 31, 27, 89, 26, 23, 36, 35, 16, 33, 45, 41, 50, 13, 32, 22,
|
|
389
|
+
29, 35, 41, 30, 25, 18, 65, 23, 31, 40, 16, 54, 42, 56, 29, 34, 13,
|
|
390
|
+
],
|
|
391
|
+
[
|
|
392
|
+
46, 37, 29, 49, 33, 25, 26, 20, 29, 22, 32, 32, 18, 29, 23, 22, 20, 22, 21,
|
|
393
|
+
20, 23, 30, 25, 22, 19, 19, 26, 68, 29, 20, 30, 52, 29, 12,
|
|
394
|
+
],
|
|
395
|
+
[
|
|
396
|
+
18, 24, 17, 24, 15, 27, 26, 35, 27, 43, 23, 24, 33, 15, 63, 10, 18, 28, 51,
|
|
397
|
+
9, 45, 34, 16, 33,
|
|
398
|
+
],
|
|
399
|
+
[
|
|
400
|
+
36, 23, 31, 24, 31, 40, 25, 35, 57, 18, 40, 15, 25, 20, 20, 31, 13, 31, 30,
|
|
401
|
+
48, 25,
|
|
402
|
+
],
|
|
403
|
+
[22, 23, 18, 22],
|
|
404
|
+
[
|
|
405
|
+
28, 36, 21, 22, 12, 21, 17, 22, 27, 27, 15, 25, 23, 52, 35, 23, 58, 30, 24,
|
|
406
|
+
42, 15, 23, 29, 22, 44, 25, 12, 25, 11, 31, 13,
|
|
407
|
+
],
|
|
408
|
+
[
|
|
409
|
+
27, 32, 39, 12, 25, 23, 29, 18, 13, 19, 27, 31, 39, 33, 37, 23, 29, 33, 43,
|
|
410
|
+
26, 22, 51, 39, 25,
|
|
411
|
+
],
|
|
412
|
+
[
|
|
413
|
+
53, 46, 28, 34, 18, 38, 51, 66, 28, 29, 43, 33, 34, 31, 34, 34, 24, 46, 21,
|
|
414
|
+
43, 29, 53,
|
|
415
|
+
],
|
|
416
|
+
[
|
|
417
|
+
18, 25, 27, 44, 27, 33, 20, 29, 37, 36, 21, 21, 25, 29, 38, 20, 41, 37, 37,
|
|
418
|
+
21, 26, 20, 37, 20, 30,
|
|
419
|
+
],
|
|
420
|
+
[
|
|
421
|
+
54, 55, 24, 43, 26, 81, 40, 40, 44, 14, 47, 40, 14, 17, 29, 43, 27, 17, 19,
|
|
422
|
+
8, 30, 19, 32, 31, 31, 32, 34, 21, 30,
|
|
423
|
+
],
|
|
424
|
+
[
|
|
425
|
+
17, 18, 17, 22, 14, 42, 22, 18, 31, 19, 23, 16, 22, 15, 19, 14, 19, 34, 11,
|
|
426
|
+
37, 20, 12, 21, 27, 28, 23, 9, 27, 36, 27, 21, 33, 25, 33, 27, 23,
|
|
427
|
+
],
|
|
428
|
+
[11, 70, 13, 24, 17, 22, 28, 36, 15, 44],
|
|
429
|
+
[11, 20, 32, 23, 19, 19, 73, 18, 38, 39, 36, 47, 31],
|
|
430
|
+
[22, 23, 15, 17, 14, 14, 10, 17, 32, 3],
|
|
431
|
+
[
|
|
432
|
+
22, 13, 26, 21, 27, 30, 21, 22, 35, 22, 20, 25, 28, 22, 35, 22, 16, 21, 29,
|
|
433
|
+
29, 34, 30, 17, 25, 6, 14, 23, 28, 25, 31, 40, 22, 33, 37, 16, 33, 24, 41,
|
|
434
|
+
30, 24, 34, 17,
|
|
435
|
+
],
|
|
436
|
+
[
|
|
437
|
+
6, 12, 8, 8, 12, 10, 17, 9, 20, 18, 7, 8, 6, 7, 5, 11, 15, 50, 14, 9, 13,
|
|
438
|
+
31, 6, 10, 22, 12, 14, 9, 11, 12, 24, 11, 22, 22, 28, 12, 40, 22, 13, 17,
|
|
439
|
+
13, 11, 5, 26, 17, 11, 9, 14, 20, 23, 19, 9, 6, 7, 23, 13, 11, 11, 17, 12,
|
|
440
|
+
8, 12, 11, 10, 13, 20, 7, 35, 36, 5, 24, 20, 28, 23, 10, 12, 20, 72, 13, 19,
|
|
441
|
+
16, 8, 18, 12, 13, 17, 7, 18, 52, 17, 16, 15, 5, 23, 11, 13, 12, 9, 9, 5, 8,
|
|
442
|
+
28, 22, 35, 45, 48, 43, 13, 31, 7, 10, 10, 9, 8, 18, 19, 2, 29, 176, 7, 8,
|
|
443
|
+
9, 4, 8, 5, 6, 5, 6, 8, 8, 3, 18, 3, 3, 21, 26, 9, 8, 24, 13, 10, 7, 12, 15,
|
|
444
|
+
21, 10, 20, 14, 9, 6,
|
|
445
|
+
],
|
|
446
|
+
[
|
|
447
|
+
33, 22, 35, 27, 23, 35, 27, 36, 18, 32, 31, 28, 25, 35, 33, 33, 28, 24, 29,
|
|
448
|
+
30, 31, 29, 35, 34, 28, 28, 27, 28, 27, 33, 31,
|
|
449
|
+
],
|
|
450
|
+
[18, 26, 22, 16, 20, 12, 29, 17, 18, 20, 10, 14],
|
|
451
|
+
[17, 17, 11, 16, 16, 13, 13, 14],
|
|
452
|
+
[
|
|
453
|
+
31, 22, 26, 6, 30, 13, 25, 22, 21, 34, 16, 6, 22, 32, 9, 14, 14, 7, 25, 6,
|
|
454
|
+
17, 25, 18, 23, 12, 21, 13, 29, 24, 33, 9, 20, 24, 17, 10, 22, 38, 22, 8,
|
|
455
|
+
31, 29, 25, 28, 28, 25, 13, 15, 22, 26, 11, 23, 15, 12, 17, 13, 12, 21, 14,
|
|
456
|
+
21, 22, 11, 12, 19, 12, 25, 24,
|
|
457
|
+
],
|
|
458
|
+
[
|
|
459
|
+
19, 37, 25, 31, 31, 30, 34, 22, 26, 25, 23, 17, 27, 22, 21, 21, 27, 23, 15,
|
|
460
|
+
18, 14, 30, 40, 10, 38, 24, 22, 17, 32, 24, 40, 44, 26, 22, 19, 32, 21, 28,
|
|
461
|
+
18, 16, 18, 22, 13, 30, 5, 28, 7, 47, 39, 46, 64, 34,
|
|
462
|
+
],
|
|
463
|
+
[22, 22, 66, 22, 22],
|
|
464
|
+
[
|
|
465
|
+
28, 10, 27, 17, 17, 14, 27, 18, 11, 22, 25, 28, 23, 23, 8, 63, 24, 32, 14,
|
|
466
|
+
49, 32, 31, 49, 27, 17, 21, 36, 26, 21, 26, 18, 32, 33, 31, 15, 38, 28, 23,
|
|
467
|
+
29, 49, 26, 20, 27, 31, 25, 24, 23, 35,
|
|
468
|
+
],
|
|
469
|
+
[21, 49, 30, 37, 31, 28, 28, 27, 27, 21, 45, 13],
|
|
470
|
+
[11, 23, 5, 19, 15, 11, 16, 14, 17, 15, 12, 14, 16, 9],
|
|
471
|
+
[20, 32, 21],
|
|
472
|
+
[15, 16, 15, 13, 27, 14, 17, 14, 15],
|
|
473
|
+
[21],
|
|
474
|
+
[17, 10, 10, 11],
|
|
475
|
+
[16, 13, 12, 13, 15, 16, 20],
|
|
476
|
+
[15, 13, 19],
|
|
477
|
+
[17, 20, 19],
|
|
478
|
+
[18, 15, 20],
|
|
479
|
+
[15, 23],
|
|
480
|
+
[21, 13, 10, 14, 11, 15, 14, 23, 17, 12, 17, 14, 9, 21],
|
|
481
|
+
[14, 17, 18, 6],
|
|
482
|
+
[
|
|
483
|
+
25, 23, 17, 25, 48, 34, 29, 34, 38, 42, 30, 50, 58, 36, 39, 28, 27, 35, 30,
|
|
484
|
+
34, 46, 46, 39, 51, 46, 75, 66, 20,
|
|
485
|
+
],
|
|
486
|
+
[45, 28, 35, 41, 43, 56, 37, 38, 50, 52, 33, 44, 37, 72, 47, 20],
|
|
487
|
+
[
|
|
488
|
+
80, 52, 38, 44, 39, 49, 50, 56, 62, 42, 54, 59, 35, 35, 32, 31, 37, 43, 48,
|
|
489
|
+
47, 38, 71, 56, 53,
|
|
490
|
+
],
|
|
491
|
+
[
|
|
492
|
+
51, 25, 36, 54, 47, 71, 53, 59, 41, 42, 57, 50, 38, 31, 27, 33, 26, 40, 42,
|
|
493
|
+
31, 25,
|
|
494
|
+
],
|
|
495
|
+
[
|
|
496
|
+
26, 47, 26, 37, 42, 15, 60, 40, 43, 48, 30, 25, 52, 28, 41, 40, 34, 28, 41,
|
|
497
|
+
38, 40, 30, 35, 27, 27, 32, 44, 31,
|
|
498
|
+
],
|
|
499
|
+
[32, 29, 31, 25, 21, 23, 25, 39, 33, 21, 36, 21, 14, 23, 33, 27],
|
|
500
|
+
[31, 16, 23, 21, 13, 20, 40, 13, 27, 33, 34, 31, 13, 40, 58, 24],
|
|
501
|
+
[24, 17, 18, 18, 21, 18, 16, 24, 15, 18, 33, 21, 14],
|
|
502
|
+
[24, 21, 29, 31, 26, 18],
|
|
503
|
+
[23, 22, 21, 32, 33, 24],
|
|
504
|
+
[30, 30, 21, 23],
|
|
505
|
+
[29, 23, 25, 18],
|
|
506
|
+
[10, 20, 13, 18, 28],
|
|
507
|
+
[12, 17, 18],
|
|
508
|
+
[20, 15, 16, 16, 25, 21],
|
|
509
|
+
[18, 26, 17, 22],
|
|
510
|
+
[16, 15, 15],
|
|
511
|
+
[25],
|
|
512
|
+
[14, 18, 19, 16, 14, 20, 28, 13, 28, 39, 40, 29, 25],
|
|
513
|
+
[27, 26, 18, 17, 20],
|
|
514
|
+
[25, 25, 22, 19, 14],
|
|
515
|
+
[21, 22, 18],
|
|
516
|
+
[10, 29, 24, 21, 21],
|
|
517
|
+
[13],
|
|
518
|
+
[14],
|
|
519
|
+
[25],
|
|
520
|
+
[
|
|
521
|
+
20, 29, 22, 11, 14, 17, 17, 13, 21, 11, 19, 17, 18, 20, 8, 21, 18, 24, 21,
|
|
522
|
+
15, 27, 21,
|
|
523
|
+
],
|
|
524
|
+
];
|
|
525
|
+
/**
|
|
526
|
+
* Constant for the ordinal number of the first verse in each chapter.
|
|
527
|
+
* Warning if you regenerate this code (from the code at the bottom of
|
|
528
|
+
* this module) then you will need to cut the psalms line in half to
|
|
529
|
+
* get it to compile under JBuilder.
|
|
530
|
+
*/
|
|
531
|
+
const ORDINAL_AT_START_OF_CHAPTER = [
|
|
532
|
+
[
|
|
533
|
+
1, 32, 57, 81, 107, 139, 161, 185, 207, 236, 268, 300, 320, 338, 362, 383,
|
|
534
|
+
399, 426, 459, 497, 515, 549, 573, 593, 660, 694, 729, 775, 797, 832, 875,
|
|
535
|
+
930, 962, 982, 1013, 1042, 1085, 1121, 1151, 1174, 1197, 1254, 1292, 1326,
|
|
536
|
+
1360, 1388, 1422, 1453, 1475, 1508,
|
|
537
|
+
],
|
|
538
|
+
[
|
|
539
|
+
1534, 1556, 1581, 1603, 1634, 1657, 1687, 1712, 1744, 1779, 1808, 1818,
|
|
540
|
+
1869, 1891, 1922, 1949, 1985, 2001, 2028, 2053, 2079, 2115, 2146, 2179,
|
|
541
|
+
2197, 2237, 2274, 2295, 2338, 2384, 2422, 2440, 2475, 2498, 2533, 2568,
|
|
542
|
+
2606, 2635, 2666, 2709,
|
|
543
|
+
],
|
|
544
|
+
[
|
|
545
|
+
2747, 2764, 2780, 2797, 2832, 2851, 2881, 2919, 2955, 2979, 2999, 3046,
|
|
546
|
+
3054, 3113, 3170, 3203, 3237, 3253, 3283, 3320, 3347, 3371, 3404, 3448,
|
|
547
|
+
3471, 3526, 3572,
|
|
548
|
+
],
|
|
549
|
+
[
|
|
550
|
+
3606, 3660, 3694, 3745, 3794, 3825, 3852, 3941, 3967, 3990, 4026, 4061,
|
|
551
|
+
4077, 4110, 4155, 4196, 4246, 4259, 4291, 4313, 4342, 4377, 4418, 4448,
|
|
552
|
+
4473, 4491, 4556, 4579, 4610, 4650, 4666, 4720, 4762, 4818, 4847, 4881,
|
|
553
|
+
],
|
|
554
|
+
[
|
|
555
|
+
4894, 4940, 4977, 5006, 5055, 5088, 5113, 5139, 5159, 5188, 5210, 5242,
|
|
556
|
+
5274, 5292, 5321, 5344, 5366, 5386, 5408, 5429, 5449, 5472, 5502, 5527,
|
|
557
|
+
5549, 5568, 5587, 5613, 5681, 5710, 5730, 5760, 5812, 5841,
|
|
558
|
+
],
|
|
559
|
+
[
|
|
560
|
+
5853, 5871, 5895, 5912, 5936, 5951, 5978, 6004, 6039, 6066, 6109, 6132,
|
|
561
|
+
6156, 6189, 6204, 6267, 6277, 6295, 6323, 6374, 6383, 6428, 6462, 6478,
|
|
562
|
+
],
|
|
563
|
+
[
|
|
564
|
+
6511, 6547, 6570, 6601, 6625, 6656, 6696, 6721, 6756, 6813, 6831, 6871,
|
|
565
|
+
6886, 6911, 6931, 6951, 6982, 6995, 7026, 7056, 7104,
|
|
566
|
+
],
|
|
567
|
+
[7129, 7151, 7174, 7192],
|
|
568
|
+
[
|
|
569
|
+
7214, 7242, 7278, 7299, 7321, 7333, 7354, 7371, 7393, 7420, 7447, 7462,
|
|
570
|
+
7487, 7510, 7562, 7597, 7620, 7678, 7708, 7732, 7774, 7789, 7812, 7841,
|
|
571
|
+
7863, 7907, 7932, 7944, 7969, 7980, 8011,
|
|
572
|
+
],
|
|
573
|
+
[
|
|
574
|
+
8024, 8051, 8083, 8122, 8134, 8159, 8182, 8211, 8229, 8242, 8261, 8288,
|
|
575
|
+
8319, 8358, 8391, 8428, 8451, 8480, 8513, 8556, 8582, 8604, 8655, 8694,
|
|
576
|
+
],
|
|
577
|
+
[
|
|
578
|
+
8719, 8772, 8818, 8846, 8880, 8898, 8936, 8987, 9053, 9081, 9110, 9153,
|
|
579
|
+
9186, 9220, 9251, 9285, 9319, 9343, 9389, 9410, 9453, 9482,
|
|
580
|
+
],
|
|
581
|
+
[
|
|
582
|
+
9535, 9553, 9578, 9605, 9649, 9676, 9709, 9729, 9758, 9795, 9831, 9852,
|
|
583
|
+
9873, 9898, 9927, 9965, 9985, 10026, 10063, 10100, 10121, 10147, 10167,
|
|
584
|
+
10204, 10224,
|
|
585
|
+
],
|
|
586
|
+
[
|
|
587
|
+
10254, 10308, 10363, 10387, 10430, 10456, 10537, 10577, 10617, 10661, 10675,
|
|
588
|
+
10722, 10762, 10776, 10793, 10822, 10865, 10892, 10909, 10928, 10936, 10966,
|
|
589
|
+
10985, 11017, 11048, 11079, 11111, 11145, 11166,
|
|
590
|
+
],
|
|
591
|
+
[
|
|
592
|
+
11196, 11213, 11231, 11248, 11270, 11284, 11326, 11348, 11366, 11397, 11416,
|
|
593
|
+
11439, 11455, 11477, 11492, 11511, 11525, 11544, 11578, 11589, 11626, 11646,
|
|
594
|
+
11658, 11679, 11706, 11734, 11757, 11766, 11793, 11829, 11856, 11877, 11910,
|
|
595
|
+
11935, 11968, 11995,
|
|
596
|
+
],
|
|
597
|
+
[12018, 12029, 12099, 12112, 12136, 12153, 12175, 12203, 12239, 12254],
|
|
598
|
+
[
|
|
599
|
+
12298, 12309, 12329, 12361, 12384, 12403, 12422, 12495, 12513, 12551, 12590,
|
|
600
|
+
12626, 12673,
|
|
601
|
+
],
|
|
602
|
+
[12704, 12726, 12749, 12764, 12781, 12795, 12809, 12819, 12836, 12868],
|
|
603
|
+
[
|
|
604
|
+
12871, 12893, 12906, 12932, 12953, 12980, 13010, 13031, 13053, 13088, 13110,
|
|
605
|
+
13130, 13155, 13183, 13205, 13240, 13262, 13278, 13299, 13328, 13357, 13391,
|
|
606
|
+
13421, 13438, 13463, 13469, 13483, 13506, 13534, 13559, 13590, 13630, 13652,
|
|
607
|
+
13685, 13722, 13738, 13771, 13795, 13836, 13866, 13890, 13924,
|
|
608
|
+
],
|
|
609
|
+
[
|
|
610
|
+
13941, 13947, 13959, 13967, 13975, 13987, 13997, 14014, 14023, 14043, 14061,
|
|
611
|
+
14068, 14076, 14082, 14089, 14094, 14105, 14120, 14170, 14184, 14193, 14206,
|
|
612
|
+
14237, 14243, 14253, 14275, 14287, 14301, 14310, 14321, 14333, 14357, 14368,
|
|
613
|
+
14390, 14412, 14440, 14452, 14492, 14514, 14527, 14544, 14557, 14568, 14573,
|
|
614
|
+
14599, 14616, 14627, 14636, 14650, 14670, 14693, 14712, 14721, 14727, 14734,
|
|
615
|
+
14757, 14770, 14781, 14792, 14809, 14821, 14829, 14841, 14852, 14862, 14875,
|
|
616
|
+
14895, 14902, 14937, 14973, 14978, 15002, 15022, 15050, 15073, 15083, 15095,
|
|
617
|
+
15115, 15187, 15200, 15219, 15235, 15243, 15261, 15273, 15286, 15303, 15310,
|
|
618
|
+
15328, 15380, 15397, 15413, 15428, 15433, 15456, 15467, 15480, 15492, 15501,
|
|
619
|
+
15510, 15515, 15523, 15551, 15573, 15608, 15653, 15701, 15744, 15757, 15788,
|
|
620
|
+
15795, 15805, 15815, 15824, 15832, 15850, 15869, 15871, 15900, 16076, 16083,
|
|
621
|
+
16091, 16100, 16104, 16112, 16117, 16123, 16128, 16134, 16142, 16150, 16153,
|
|
622
|
+
16171, 16174, 16177, 16198, 16224, 16233, 16241, 16265, 16278, 16288, 16295,
|
|
623
|
+
16307, 16322, 16343, 16353, 16373, 16387, 16396,
|
|
624
|
+
],
|
|
625
|
+
[
|
|
626
|
+
16402, 16435, 16457, 16492, 16519, 16542, 16577, 16604, 16640, 16658, 16690,
|
|
627
|
+
16721, 16749, 16774, 16809, 16842, 16875, 16903, 16927, 16956, 16986, 17017,
|
|
628
|
+
17046, 17081, 17115, 17143, 17171, 17198, 17226, 17253, 17286,
|
|
629
|
+
],
|
|
630
|
+
[
|
|
631
|
+
17317, 17335, 17361, 17383, 17399, 17419, 17431, 17460, 17477, 17495, 17515,
|
|
632
|
+
17525,
|
|
633
|
+
],
|
|
634
|
+
[17539, 17556, 17573, 17584, 17600, 17616, 17629, 17642],
|
|
635
|
+
[
|
|
636
|
+
17656, 17687, 17709, 17735, 17741, 17771, 17784, 17809, 17831, 17852, 17886,
|
|
637
|
+
17902, 17908, 17930, 17962, 17971, 17985, 17999, 18006, 18031, 18037, 18054,
|
|
638
|
+
18079, 18097, 18120, 18132, 18153, 18166, 18195, 18219, 18252, 18261, 18281,
|
|
639
|
+
18305, 18322, 18332, 18354, 18392, 18414, 18422, 18453, 18482, 18507, 18535,
|
|
640
|
+
18563, 18588, 18601, 18616, 18638, 18664, 18675, 18698, 18713, 18725, 18742,
|
|
641
|
+
18755, 18767, 18788, 18802, 18823, 18845, 18856, 18868, 18887, 18899, 18924,
|
|
642
|
+
],
|
|
643
|
+
[
|
|
644
|
+
18948, 18967, 19004, 19029, 19060, 19091, 19121, 19155, 19177, 19203, 19228,
|
|
645
|
+
19251, 19268, 19295, 19317, 19338, 19359, 19386, 19409, 19424, 19442, 19456,
|
|
646
|
+
19486, 19526, 19536, 19574, 19598, 19620, 19637, 19669, 19693, 19733, 19777,
|
|
647
|
+
19803, 19825, 19844, 19876, 19897, 19925, 19943, 19959, 19977, 19999, 20012,
|
|
648
|
+
20042, 20047, 20075, 20082, 20129, 20168, 20214, 20278,
|
|
649
|
+
],
|
|
650
|
+
[20312, 20334, 20356, 20422, 20444],
|
|
651
|
+
[
|
|
652
|
+
20466, 20494, 20504, 20531, 20548, 20565, 20579, 20606, 20624, 20635, 20657,
|
|
653
|
+
20682, 20710, 20733, 20756, 20764, 20827, 20851, 20883, 20897, 20946, 20978,
|
|
654
|
+
21009, 21058, 21085, 21102, 21123, 21159, 21185, 21206, 21232, 21250, 21282,
|
|
655
|
+
21315, 21346, 21361, 21399, 21427, 21450, 21479, 21528, 21554, 21574, 21601,
|
|
656
|
+
21632, 21657, 21681, 21704,
|
|
657
|
+
],
|
|
658
|
+
[
|
|
659
|
+
21739, 21760, 21809, 21839, 21876, 21907, 21935, 21963, 21990, 22017, 22038,
|
|
660
|
+
22083,
|
|
661
|
+
],
|
|
662
|
+
[
|
|
663
|
+
22096, 22107, 22130, 22135, 22154, 22169, 22180, 22196, 22210, 22227, 22242,
|
|
664
|
+
22254, 22268, 22284,
|
|
665
|
+
],
|
|
666
|
+
[22293, 22313, 22345],
|
|
667
|
+
[22366, 22381, 22397, 22412, 22425, 22452, 22466, 22483, 22497],
|
|
668
|
+
[22512],
|
|
669
|
+
[22533, 22550, 22560, 22570],
|
|
670
|
+
[22581, 22597, 22610, 22622, 22635, 22650, 22666],
|
|
671
|
+
[22686, 22701, 22714],
|
|
672
|
+
[22733, 22750, 22770],
|
|
673
|
+
[22789, 22807, 22822],
|
|
674
|
+
[22842, 22857],
|
|
675
|
+
[
|
|
676
|
+
22880, 22901, 22914, 22924, 22938, 22949, 22964, 22978, 23001, 23018, 23030,
|
|
677
|
+
23047, 23061, 23070,
|
|
678
|
+
],
|
|
679
|
+
[23091, 23105, 23122, 23140],
|
|
680
|
+
[
|
|
681
|
+
23146, 23171, 23194, 23211, 23236, 23284, 23318, 23347, 23381, 23419, 23461,
|
|
682
|
+
23491, 23541, 23599, 23635, 23674, 23702, 23729, 23764, 23794, 23828, 23874,
|
|
683
|
+
23920, 23959, 24010, 24056, 24131, 24197,
|
|
684
|
+
],
|
|
685
|
+
[
|
|
686
|
+
24217, 24262, 24290, 24325, 24366, 24409, 24465, 24502, 24540, 24590, 24642,
|
|
687
|
+
24675, 24719, 24756, 24828, 24875,
|
|
688
|
+
],
|
|
689
|
+
[
|
|
690
|
+
24895, 24975, 25027, 25065, 25109, 25148, 25197, 25247, 25303, 25365, 25407,
|
|
691
|
+
25461, 25520, 25555, 25590, 25622, 25653, 25690, 25733, 25781, 25828, 25866,
|
|
692
|
+
25937, 25993,
|
|
693
|
+
],
|
|
694
|
+
[
|
|
695
|
+
26046, 26097, 26122, 26158, 26212, 26259, 26330, 26383, 26442, 26483, 26525,
|
|
696
|
+
26582, 26632, 26670, 26701, 26728, 26761, 26787, 26827, 26869, 26900,
|
|
697
|
+
],
|
|
698
|
+
[
|
|
699
|
+
26925, 26951, 26998, 27024, 27061, 27103, 27118, 27178, 27218, 27261, 27309,
|
|
700
|
+
27339, 27364, 27416, 27444, 27485, 27525, 27559, 27587, 27628, 27666, 27706,
|
|
701
|
+
27736, 27771, 27798, 27825, 27857, 27901,
|
|
702
|
+
],
|
|
703
|
+
[
|
|
704
|
+
27932, 27964, 27993, 28024, 28049, 28070, 28093, 28118, 28157, 28190, 28211,
|
|
705
|
+
28247, 28268, 28282, 28305, 28338,
|
|
706
|
+
],
|
|
707
|
+
[
|
|
708
|
+
28365, 28396, 28412, 28435, 28456, 28469, 28489, 28529, 28542, 28569, 28602,
|
|
709
|
+
28636, 28667, 28680, 28720, 28778,
|
|
710
|
+
],
|
|
711
|
+
[
|
|
712
|
+
28802, 28826, 28843, 28861, 28879, 28900, 28918, 28934, 28958, 28973, 28991,
|
|
713
|
+
29024, 29045,
|
|
714
|
+
],
|
|
715
|
+
[29059, 29083, 29104, 29133, 29164, 29190],
|
|
716
|
+
[29208, 29231, 29253, 29274, 29306, 29339],
|
|
717
|
+
[29363, 29393, 29423, 29444],
|
|
718
|
+
[29467, 29496, 29519, 29544],
|
|
719
|
+
[29562, 29572, 29592, 29605, 29623],
|
|
720
|
+
[29651, 29663, 29680],
|
|
721
|
+
[29698, 29718, 29733, 29749, 29765, 29790],
|
|
722
|
+
[29811, 29829, 29855, 29872],
|
|
723
|
+
[29894, 29910, 29925],
|
|
724
|
+
[29940],
|
|
725
|
+
[
|
|
726
|
+
29965, 29979, 29997, 30016, 30032, 30046, 30066, 30094, 30107, 30135, 30174,
|
|
727
|
+
30214, 30243,
|
|
728
|
+
],
|
|
729
|
+
[30268, 30295, 30321, 30339, 30356],
|
|
730
|
+
[30376, 30401, 30426, 30448, 30467],
|
|
731
|
+
[30481, 30502, 30524],
|
|
732
|
+
[30542, 30552, 30581, 30605, 30626],
|
|
733
|
+
[30647],
|
|
734
|
+
[30660],
|
|
735
|
+
[30674],
|
|
736
|
+
[
|
|
737
|
+
30699, 30719, 30748, 30770, 30781, 30795, 30812, 30829, 30842, 30863, 30874,
|
|
738
|
+
30893, 30910, 30928, 30948, 30956, 30977, 30995, 31019, 31040, 31055, 31082,
|
|
739
|
+
],
|
|
740
|
+
];
|
|
741
|
+
/** Constant for the ordinal number of the first verse in each book */
|
|
742
|
+
const ORDINAL_AT_START_OF_BOOK = [
|
|
743
|
+
1, 1534, 2747, 3606, 4894, 5853, 6511, 7129, 7214, 8024, 8719, 9535, 10254,
|
|
744
|
+
11196, 12018, 12298, 12704, 12871, 13941, 16402, 17317, 17539, 17656, 18948,
|
|
745
|
+
20312, 20466, 21739, 22096, 22293, 22366, 22512, 22533, 22581, 22686, 22733,
|
|
746
|
+
22789, 22842, 22880, 23091, 23146, 24217, 24895, 26046, 26925, 27932, 28365,
|
|
747
|
+
28802, 29059, 29208, 29363, 29467, 29562, 29651, 29698, 29811, 29894, 29940,
|
|
748
|
+
29965, 30268, 30376, 30481, 30542, 30647, 30660, 30674, 30699,
|
|
749
|
+
];
|
|
750
|
+
/**
|
|
751
|
+
* What is the canonical short name for a book?
|
|
752
|
+
*/
|
|
753
|
+
export function getShortName(book) {
|
|
754
|
+
if (book > BOOKS_IN_BIBLE || book <= 0) {
|
|
755
|
+
throw new Error(`Illegal book number (${book}). ` +
|
|
756
|
+
`Must be between 1 and ${BOOKS_IN_BIBLE}.`);
|
|
757
|
+
}
|
|
758
|
+
return SHORT_NAMES[book - 1];
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* What is the canonical long name for a book?
|
|
762
|
+
*/
|
|
763
|
+
export function getLongName(book) {
|
|
764
|
+
if (book > BOOKS_IN_BIBLE || book <= 0) {
|
|
765
|
+
throw new Error(`Illegal book number (${book}). ` +
|
|
766
|
+
`Must be between 1 and ${BOOKS_IN_BIBLE}.`);
|
|
767
|
+
}
|
|
768
|
+
return LONG_NAMES[book - 1];
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* How many chapters are there in the given book?
|
|
772
|
+
*/
|
|
773
|
+
export function chaptersInBook(book) {
|
|
774
|
+
if (book > BOOKS_IN_BIBLE || book <= 0) {
|
|
775
|
+
throw new Error(`Illegal book number (${book}). ` +
|
|
776
|
+
`Must be between 1 and ${BOOKS_IN_BIBLE}.`);
|
|
777
|
+
}
|
|
778
|
+
return CHAPTERS_IN_BOOK[book - 1];
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* How many verses are there in the given chapter?
|
|
782
|
+
*/
|
|
783
|
+
export function versesInChapter(book, chapter) {
|
|
784
|
+
if (book > BOOKS_IN_BIBLE || book <= 0) {
|
|
785
|
+
throw new Error(`Illegal book number (${book}). ` +
|
|
786
|
+
`Must be between 1 and ${BOOKS_IN_BIBLE}.`);
|
|
787
|
+
}
|
|
788
|
+
const forBook = VERSES_IN_CHAPTER[book - 1];
|
|
789
|
+
if (chapter > forBook.length || chapter <= 0) {
|
|
790
|
+
throw new Error(`Illegal chapter number (${chapter}). ` +
|
|
791
|
+
`Must be between 1 and ${forBook.length} ` +
|
|
792
|
+
`for book ${book}.`);
|
|
793
|
+
}
|
|
794
|
+
return forBook[chapter - 1];
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* How many verses are there in the Bible? Somewhat for completeness
|
|
798
|
+
*/
|
|
799
|
+
export function versesInBible() {
|
|
800
|
+
return VERSES_IN_BIBLE;
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* How many chapters are there in the Bible? Somewhat for completeness
|
|
804
|
+
*/
|
|
805
|
+
export function chaptersInBible() {
|
|
806
|
+
return CHAPTERS_IN_BIBLE;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* How many books are there in the Bible? Somewhat for completeness
|
|
810
|
+
*/
|
|
811
|
+
export function booksInBible() {
|
|
812
|
+
return BOOKS_IN_BIBLE;
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Accessor for the full list of names of the books of the Bible.
|
|
816
|
+
*/
|
|
817
|
+
export function bookNames() {
|
|
818
|
+
return LONG_NAMES;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Accessor for the full list of names of the books of the Bible.
|
|
822
|
+
*/
|
|
823
|
+
export function shortBookNames() {
|
|
824
|
+
return SHORT_NAMES;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Where does this verse come in the Bible? Starting with Gen 1:1 as
|
|
828
|
+
* number 1 counting up one per verse and not resetting at each new
|
|
829
|
+
* chapter.
|
|
830
|
+
* @see decodeOrdinal()
|
|
831
|
+
* @param book The book part of the reference.
|
|
832
|
+
* @param chapter The current chapter
|
|
833
|
+
* @param verse The current verse
|
|
834
|
+
* @returns The ordinal number of the referenced verse
|
|
835
|
+
*/
|
|
836
|
+
export function verseOrdinal(book, chapter, verse) {
|
|
837
|
+
const verseCount = versesInChapter(book, chapter);
|
|
838
|
+
if (verse > verseCount || verse <= 0) {
|
|
839
|
+
throw new Error(`Illegal verse number (${verse}). ` +
|
|
840
|
+
`Must be between 1 and ${verseCount} ` +
|
|
841
|
+
`for book ${book}, chapter ${chapter}.`);
|
|
842
|
+
}
|
|
843
|
+
return ORDINAL_AT_START_OF_CHAPTER[book - 1][chapter - 1] + verse - 1;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Where does this verse come in the Bible? Starting with Gen 1:1 as
|
|
847
|
+
* number 1 counting up one per verse and not resetting at each new
|
|
848
|
+
* chapter.
|
|
849
|
+
* @see verseOrdinal()
|
|
850
|
+
* @param ordinal The ordinal number of the verse
|
|
851
|
+
* @returns A 3 tuple; book, chapter, verse
|
|
852
|
+
*/
|
|
853
|
+
export function decodeOrdinal(ordinal) {
|
|
854
|
+
if (ordinal < 1 || ordinal > VERSES_IN_BIBLE) {
|
|
855
|
+
throw new Error(`${ordinal} is out of range as a verse ordinal.`);
|
|
856
|
+
}
|
|
857
|
+
for (let b = BOOKS_IN_BIBLE; b > 0; b--) {
|
|
858
|
+
if (ordinal >= ORDINAL_AT_START_OF_BOOK[b - 1]) {
|
|
859
|
+
const cib = chaptersInBook(b);
|
|
860
|
+
for (let c = cib; c > 0; c--) {
|
|
861
|
+
if (ordinal >= ORDINAL_AT_START_OF_CHAPTER[b - 1][c - 1]) {
|
|
862
|
+
return [
|
|
863
|
+
b,
|
|
864
|
+
c,
|
|
865
|
+
ordinal - ORDINAL_AT_START_OF_CHAPTER[b - 1][c - 1] + 1,
|
|
866
|
+
];
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
/* istanbul ignore next */
|
|
872
|
+
throw new Error(`decodeOrdinal error`);
|
|
873
|
+
}
|
|
874
|
+
//# sourceMappingURL=bible-info.js.map
|