@helloao/tools 0.0.4 → 0.0.6-alpha
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 +6 -6
- package/dist/cjs/generation/api.cjs +240 -0
- package/dist/cjs/generation/api.cjs.map +7 -0
- package/dist/cjs/generation/audio.cjs +83 -0
- package/dist/cjs/generation/audio.cjs.map +7 -0
- package/dist/cjs/generation/book-order.cjs +508 -0
- package/dist/cjs/generation/book-order.cjs.map +7 -0
- package/dist/cjs/generation/common-types.cjs +17 -0
- package/dist/cjs/generation/common-types.cjs.map +7 -0
- package/dist/cjs/generation/dataset.cjs +158 -0
- package/dist/cjs/generation/dataset.cjs.map +7 -0
- package/dist/cjs/generation/index.cjs +51 -0
- package/dist/cjs/generation/index.cjs.map +7 -0
- package/dist/cjs/index.cjs +45 -0
- package/dist/cjs/index.cjs.map +7 -0
- package/dist/cjs/parser/codex-parser.cjs +176 -0
- package/dist/cjs/parser/codex-parser.cjs.map +7 -0
- package/dist/cjs/parser/index.cjs +48 -0
- package/dist/cjs/parser/index.cjs.map +7 -0
- package/dist/cjs/parser/iterators.cjs +204 -0
- package/dist/cjs/parser/iterators.cjs.map +7 -0
- package/dist/cjs/parser/types.cjs +17 -0
- package/dist/cjs/parser/types.cjs.map +7 -0
- package/dist/cjs/parser/usfm-parser.cjs +791 -0
- package/dist/cjs/parser/usfm-parser.cjs.map +7 -0
- package/dist/cjs/parser/usx-parser.cjs +471 -0
- package/dist/cjs/parser/usx-parser.cjs.map +7 -0
- package/dist/cjs/utils.cjs +85 -0
- package/dist/cjs/utils.cjs.map +7 -0
- package/dist/esm/generation/api.js +198 -0
- package/dist/esm/generation/api.js.map +7 -0
- package/dist/esm/generation/audio.js +53 -0
- package/dist/esm/generation/audio.js.map +7 -0
- package/dist/esm/generation/book-order.js +478 -0
- package/dist/esm/generation/book-order.js.map +7 -0
- package/dist/esm/generation/common-types.js +2 -0
- package/dist/esm/generation/common-types.js.map +7 -0
- package/dist/esm/generation/dataset.js +132 -0
- package/dist/esm/generation/dataset.js.map +7 -0
- package/dist/esm/generation/index.js +8 -0
- package/dist/esm/generation/index.js.map +7 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/parser/codex-parser.js +144 -0
- package/dist/esm/parser/codex-parser.js.map +7 -0
- package/dist/esm/parser/index.js +8 -0
- package/dist/esm/parser/index.js.map +7 -0
- package/dist/esm/parser/iterators.js +152 -0
- package/dist/esm/parser/iterators.js.map +7 -0
- package/dist/esm/parser/types.js +2 -0
- package/dist/esm/parser/types.js.map +7 -0
- package/dist/esm/parser/usfm-parser.js +749 -0
- package/dist/esm/parser/usfm-parser.js.map +7 -0
- package/dist/esm/parser/usx-parser.js +447 -0
- package/dist/esm/parser/usx-parser.js.map +7 -0
- package/dist/esm/utils.js +51 -0
- package/dist/esm/utils.js.map +7 -0
- package/{generation → dist/types/generation}/api.d.ts +46 -5
- package/{generation → dist/types/generation}/audio.d.ts +1 -1
- package/{generation → dist/types/generation}/dataset.d.ts +1 -1
- package/dist/types/generation/index.d.ts +7 -0
- package/dist/types/index.d.ts +5 -0
- package/{parser → dist/types/parser}/codex-parser.d.ts +1 -1
- package/dist/types/parser/index.d.ts +7 -0
- package/{parser → dist/types/parser}/usfm-parser.d.ts +1 -1
- package/{parser → dist/types/parser}/usx-parser.d.ts +2 -2
- package/package.json +25 -4
- package/generation/api.js +0 -153
- package/generation/api.spec.d.ts +0 -2
- package/generation/api.spec.js +0 -463
- package/generation/audio.js +0 -60
- package/generation/audio.spec.d.ts +0 -2
- package/generation/audio.spec.js +0 -36
- package/generation/book-order.js +0 -494
- package/generation/book-order.spec.d.ts +0 -2
- package/generation/book-order.spec.js +0 -8
- package/generation/common-types.js +0 -2
- package/generation/dataset.js +0 -106
- package/generation/index.d.ts +0 -7
- package/generation/index.js +0 -38
- package/index.d.ts +0 -5
- package/index.js +0 -32
- package/parser/codex-parser.js +0 -160
- package/parser/codex-parser.spec.d.ts +0 -2
- package/parser/codex-parser.spec.js +0 -645
- package/parser/index.d.ts +0 -7
- package/parser/index.js +0 -35
- package/parser/iterators.js +0 -222
- package/parser/iterators.spec.d.ts +0 -2
- package/parser/iterators.spec.js +0 -174
- package/parser/types.js +0 -2
- package/parser/usfm-parser.js +0 -840
- package/parser/usfm-parser.spec.d.ts +0 -2
- package/parser/usfm-parser.spec.js +0 -1593
- package/parser/usx-parser.js +0 -425
- package/parser/usx-parser.spec.d.ts +0 -2
- package/parser/usx-parser.spec.js +0 -1260
- package/utils.js +0 -73
- package/utils.spec.d.ts +0 -2
- package/utils.spec.js +0 -42
- /package/{generation → dist/types/generation}/book-order.d.ts +0 -0
- /package/{generation → dist/types/generation}/common-types.d.ts +0 -0
- /package/{parser → dist/types/parser}/iterators.d.ts +0 -0
- /package/{parser → dist/types/parser}/types.d.ts +0 -0
- /package/{utils.d.ts → dist/types/utils.d.ts} +0 -0
package/utils.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeLanguage = normalizeLanguage;
|
|
4
|
-
exports.getTranslationId = getTranslationId;
|
|
5
|
-
exports.isEmptyOrWhitespace = isEmptyOrWhitespace;
|
|
6
|
-
exports.getFirstNonEmpty = getFirstNonEmpty;
|
|
7
|
-
exports.parseVerseReference = parseVerseReference;
|
|
8
|
-
/**
|
|
9
|
-
* Normalizes the given language code into a ISO 639 code.
|
|
10
|
-
* @param language The language code to normalize.
|
|
11
|
-
*/
|
|
12
|
-
function normalizeLanguage(language) {
|
|
13
|
-
return language;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* The map of translation IDs from fetch.bible to their translation ID in the API.
|
|
17
|
-
*/
|
|
18
|
-
const TRANSLATION_ID_MAP = new Map([
|
|
19
|
-
['eng_bsb', 'BSB'],
|
|
20
|
-
['arb_nav', 'ARBNAV'],
|
|
21
|
-
['eng_webp', 'ENGWEBP'],
|
|
22
|
-
['hin_irv', 'HINIRV'],
|
|
23
|
-
['hbo_mas', 'HBOMAS'],
|
|
24
|
-
]);
|
|
25
|
-
/**
|
|
26
|
-
* Gets the ID of the translation.
|
|
27
|
-
* @param translation The translation to get the ID for.
|
|
28
|
-
*/
|
|
29
|
-
function getTranslationId(translationId) {
|
|
30
|
-
return TRANSLATION_ID_MAP.get(translationId) ?? translationId;
|
|
31
|
-
}
|
|
32
|
-
function isEmptyOrWhitespace(str) {
|
|
33
|
-
return !str || /^\s*$/.test(str);
|
|
34
|
-
}
|
|
35
|
-
function getFirstNonEmpty(...values) {
|
|
36
|
-
for (let value of values) {
|
|
37
|
-
if (!isEmptyOrWhitespace(value)) {
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
throw new Error('All values are empty or whitespace!');
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Parses the given verse reference.
|
|
45
|
-
* Formatted like "GEN 1:1".
|
|
46
|
-
*
|
|
47
|
-
* @param text The reference to parse.
|
|
48
|
-
*/
|
|
49
|
-
function parseVerseReference(text) {
|
|
50
|
-
const match = text.match(/^\s*([A-Z]+)\s+(\d+):(\d+)/);
|
|
51
|
-
if (!match) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
const [reference, book, chapterStr, verseStr] = match;
|
|
55
|
-
const chapter = parseInt(chapterStr);
|
|
56
|
-
const verse = parseInt(verseStr);
|
|
57
|
-
if (isNaN(chapter) || isNaN(verse)) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
if (reference.length !== text.length) {
|
|
61
|
-
return {
|
|
62
|
-
book,
|
|
63
|
-
chapter,
|
|
64
|
-
verse,
|
|
65
|
-
content: text.substring(reference.length).trim(),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
book,
|
|
70
|
-
chapter,
|
|
71
|
-
verse,
|
|
72
|
-
};
|
|
73
|
-
}
|
package/utils.spec.d.ts
DELETED
package/utils.spec.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("./utils");
|
|
4
|
-
describe('isEmptyOrWhitespace()', () => {
|
|
5
|
-
const cases = [
|
|
6
|
-
['emtpy', true, ''],
|
|
7
|
-
['null', true, null],
|
|
8
|
-
['undef', true, undefined],
|
|
9
|
-
['space', true, ' '],
|
|
10
|
-
['tab', true, '\t'],
|
|
11
|
-
['letters', false, 'abc'],
|
|
12
|
-
['newline', true, '\n'],
|
|
13
|
-
];
|
|
14
|
-
it.each(cases)('should return %s for %s', (_desc, expected, input) => {
|
|
15
|
-
expect((0, utils_1.isEmptyOrWhitespace)(input)).toBe(expected);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
describe('parseVerseReference()', () => {
|
|
19
|
-
const cases = [
|
|
20
|
-
['GEN 1:1', { book: 'GEN', chapter: 1, verse: 1 }],
|
|
21
|
-
['EXO 1:1', { book: 'EXO', chapter: 1, verse: 1 }],
|
|
22
|
-
['PSA 110:1', { book: 'PSA', chapter: 110, verse: 1 }],
|
|
23
|
-
['JHN 1:50', { book: 'JHN', chapter: 1, verse: 50 }],
|
|
24
|
-
];
|
|
25
|
-
it.each(cases)('should parse %s', (input, expected) => {
|
|
26
|
-
expect((0, utils_1.parseVerseReference)(input)).toEqual(expected);
|
|
27
|
-
});
|
|
28
|
-
const verseCases = [
|
|
29
|
-
['GEN 1:1 In the beginning, God created the Heavens and the Earth.',
|
|
30
|
-
{ book: 'GEN', chapter: 1, verse: 1, content: 'In the beginning, God created the Heavens and the Earth.' }],
|
|
31
|
-
['EXO 1:1 These are the names of the sons of Israel who came to Egypt with Jacob, each with his household:',
|
|
32
|
-
{ book: 'EXO', chapter: 1, verse: 1, content: 'These are the names of the sons of Israel who came to Egypt with Jacob, each with his household:' }],
|
|
33
|
-
['PSA 110:1 The Lord says to my Lord: \n“Sit at my right hand, \nuntil I make your enemies your footstool.”', {
|
|
34
|
-
book: 'PSA', chapter: 110, verse: 1, content: 'The Lord says to my Lord: \n“Sit at my right hand, \nuntil I make your enemies your footstool.”'
|
|
35
|
-
}],
|
|
36
|
-
['JHN 1:50 Jesus answered him, “Because I said to you, ‘I saw you under the fig tree,’ do you believe? You will see greater things than these.”',
|
|
37
|
-
{ book: 'JHN', chapter: 1, verse: 50, content: 'Jesus answered him, “Because I said to you, ‘I saw you under the fig tree,’ do you believe? You will see greater things than these.”' }],
|
|
38
|
-
];
|
|
39
|
-
it.each(verseCases)('should parse the reference from %s', (input, expected) => {
|
|
40
|
-
expect((0, utils_1.parseVerseReference)(input)).toEqual(expected);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|