proskomma-core 0.9.18 → 0.9.19

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 (126) hide show
  1. package/dist/bundle.js +1 -0
  2. package/dist/index.cjs +1 -0
  3. package/dist/module.mjs +15888 -0
  4. package/package.json +23 -34
  5. package/dist/index.js +0 -8
  6. package/dist/index.js.LICENSE.txt +0 -23
  7. package/esm/package.json +0 -3
  8. package/esm/wrapper.mjs +0 -7
  9. package/informations/meeting_01_march_2023.md +0 -38
  10. package/src/graph/index.cjs +0 -201
  11. package/src/graph/lib/do_cv.cjs +0 -249
  12. package/src/graph/lib/dump.cjs +0 -40
  13. package/src/graph/lib/remake_blocks.cjs +0 -57
  14. package/src/graph/lib/sequence_chars.cjs +0 -84
  15. package/src/graph/lib/sort.cjs +0 -39
  16. package/src/graph/lib/tribos.cjs +0 -97
  17. package/src/graph/lib/tribos_expression.cjs +0 -556
  18. package/src/graph/lib/tribos_ohm_UNUSED.cjs +0 -37
  19. package/src/graph/lib/tribos_step.cjs +0 -434
  20. package/src/graph/mutations/add.cjs +0 -91
  21. package/src/graph/mutations/delete.cjs +0 -61
  22. package/src/graph/mutations/index.cjs +0 -54
  23. package/src/graph/mutations/rehash.cjs +0 -17
  24. package/src/graph/mutations/tags.cjs +0 -120
  25. package/src/graph/mutations/update.cjs +0 -210
  26. package/src/graph/mutations/versification.cjs +0 -96
  27. package/src/graph/queries/block.cjs +0 -228
  28. package/src/graph/queries/cIndex.cjs +0 -87
  29. package/src/graph/queries/cell.cjs +0 -42
  30. package/src/graph/queries/cv.cjs +0 -19
  31. package/src/graph/queries/cvBook.cjs +0 -16
  32. package/src/graph/queries/cvChapter.cjs +0 -16
  33. package/src/graph/queries/cvIndex.cjs +0 -47
  34. package/src/graph/queries/cvNavigation.cjs +0 -116
  35. package/src/graph/queries/cvVerseElement.cjs +0 -84
  36. package/src/graph/queries/cvVerses.cjs +0 -14
  37. package/src/graph/queries/doc_set.cjs +0 -220
  38. package/src/graph/queries/document.cjs +0 -555
  39. package/src/graph/queries/idParts.cjs +0 -30
  40. package/src/graph/queries/index.cjs +0 -151
  41. package/src/graph/queries/inputBlockSpec.cjs +0 -17
  42. package/src/graph/queries/inputItemObject.cjs +0 -12
  43. package/src/graph/queries/input_att_spec.cjs +0 -14
  44. package/src/graph/queries/input_key_matches.cjs +0 -11
  45. package/src/graph/queries/input_key_value.cjs +0 -11
  46. package/src/graph/queries/input_key_values.cjs +0 -11
  47. package/src/graph/queries/input_selector_spec.cjs +0 -19
  48. package/src/graph/queries/item.cjs +0 -71
  49. package/src/graph/queries/itemGroup.cjs +0 -75
  50. package/src/graph/queries/key_value.cjs +0 -18
  51. package/src/graph/queries/kv_entry.cjs +0 -21
  52. package/src/graph/queries/kv_sequence.cjs +0 -151
  53. package/src/graph/queries/node.cjs +0 -44
  54. package/src/graph/queries/orig.cjs +0 -11
  55. package/src/graph/queries/regex_index.cjs +0 -18
  56. package/src/graph/queries/row_equals_spec.cjs +0 -11
  57. package/src/graph/queries/row_match_spec.cjs +0 -11
  58. package/src/graph/queries/selector_spec.cjs +0 -29
  59. package/src/graph/queries/sequence.cjs +0 -314
  60. package/src/graph/queries/table_sequence.cjs +0 -192
  61. package/src/graph/queries/tree_sequence.cjs +0 -58
  62. package/src/graph/queries/verseNumber.cjs +0 -44
  63. package/src/graph/queries/verseRange.cjs +0 -11
  64. package/src/graph/queries/versification.cjs +0 -25
  65. package/src/index.cjs +0 -583
  66. package/src/model/doc_set.cjs +0 -389
  67. package/src/model/doc_set_helpers/block.cjs +0 -232
  68. package/src/model/doc_set_helpers/enum.cjs +0 -87
  69. package/src/model/doc_set_helpers/item.cjs +0 -198
  70. package/src/model/doc_set_helpers/rehash.cjs +0 -53
  71. package/src/model/doc_set_helpers/selectors.cjs +0 -58
  72. package/src/model/doc_set_helpers/serialize.cjs +0 -22
  73. package/src/model/doc_set_helpers/unsuccinctify.cjs +0 -288
  74. package/src/model/doc_set_helpers/update.cjs +0 -290
  75. package/src/model/document.cjs +0 -369
  76. package/src/model/document_helpers/blocks.cjs +0 -135
  77. package/src/model/document_helpers/chapter_verse.cjs +0 -291
  78. package/src/model/document_helpers/pre_enums.cjs +0 -67
  79. package/src/model/document_helpers/sequences.cjs +0 -205
  80. package/src/model/document_helpers/serialize_succinct.cjs +0 -55
  81. package/src/model/document_helpers/succinct_filter.cjs +0 -102
  82. package/src/model/versifications/eng_vrs.cjs +0 -455
  83. package/src/model/versifications/index.cjs +0 -38
  84. package/src/model/versifications/lxx_vrs.cjs +0 -950
  85. package/src/model/versifications/org_vrs.cjs +0 -155
  86. package/src/model/versifications/rsc_vrs.cjs +0 -342
  87. package/src/model/versifications/rso_vrs.cjs +0 -541
  88. package/src/model/versifications/vul_vrs.cjs +0 -835
  89. package/src/parser/index.cjs +0 -504
  90. package/src/parser/lexers/index.cjs +0 -11
  91. package/src/parser/lexers/lexingRegexes.cjs +0 -45
  92. package/src/parser/lexers/nodes.cjs +0 -123
  93. package/src/parser/lexers/object_for_fragment.cjs +0 -123
  94. package/src/parser/lexers/tsv.cjs +0 -45
  95. package/src/parser/lexers/usfm.cjs +0 -17
  96. package/src/parser/lexers/usx/index.cjs +0 -7
  97. package/src/parser/lexers/usx/usx_lexer.cjs +0 -321
  98. package/src/parser/lib/tokenize.cjs +0 -37
  99. package/src/parser/model/index.cjs +0 -637
  100. package/src/parser/parser_specs.cjs +0 -781
  101. package/src/pipelines/perf2x/index.cjs +0 -7
  102. package/src/pipelines/perf2x/perf2PkJsonPipeline.json +0 -41
  103. package/src/pipelines/perf2x/perf2usfmPipeline.json +0 -65
  104. package/src/transforms/calculateUsfmChapterPositions.cjs +0 -106
  105. package/src/transforms/index.cjs +0 -9
  106. package/src/transforms/perf2PkJson.cjs +0 -534
  107. package/src/transforms/perf2usfm.cjs +0 -294
  108. package/src/util/byteArray.cjs +0 -251
  109. package/src/util/canons.cjs +0 -117
  110. package/src/util/enums.cjs +0 -41
  111. package/src/util/generateId.cjs +0 -6
  112. package/src/util/graftDefs.cjs +0 -15
  113. package/src/util/index.cjs +0 -29
  114. package/src/util/inspectSuccinct.cjs +0 -59
  115. package/src/util/itemDefs.cjs +0 -33
  116. package/src/util/parserConstantDefs.cjs +0 -30
  117. package/src/util/scopeDefs.cjs +0 -173
  118. package/src/util/scriptlike/blocksSpec.cjs +0 -192
  119. package/src/util/scriptlike/dodson_lexicon.xsl +0 -19
  120. package/src/util/scriptlike/dodson_lexicon_to_entries.cjs +0 -85
  121. package/src/util/scriptlike/open_scriptures_hebrew_lexicon.xsl +0 -28
  122. package/src/util/scriptlike/open_scriptures_hebrew_lexicon_to_entries.cjs +0 -85
  123. package/src/util/succinct.cjs +0 -159
  124. package/src/util/tags.cjs +0 -28
  125. package/src/util/tokenDefs.cjs +0 -27
  126. package/src/util/versification.cjs +0 -364
@@ -1,294 +0,0 @@
1
- const { PerfRenderFromJson } = require('proskomma-json-tools');
2
-
3
- const oneifyTag = t => {
4
- if (['toc', 'toca', 'mt', 'imt', 's', 'ms', 'mte', 'sd'].includes(t)) {
5
- return t + '1';
6
- }
7
- return t;
8
- };
9
-
10
- const buildMilestone = (atts, type) => {
11
- let str=`\\${type}-s |`;
12
-
13
- for (let [key, value] of Object.entries(atts)) {
14
- if (key === 'x-morph') {
15
- str = str + oneifyTag(key) + '="' + value.join(',') + '" ';
16
- } else {
17
- str = str + oneifyTag(key) + '="' + value + '" ';
18
- }
19
- };
20
- return str + '\\*';
21
- };
22
-
23
- const buildEndWrapper = (atts, type, isnested = false) => {
24
- let str='|';
25
-
26
- for (let [key, value] of Object.entries(atts)) {
27
- str = str + oneifyTag(key) + '="' + value + '" ';
28
- };
29
- str = str + '\\';
30
-
31
- // if it's nested, we simply add a "+" sign before the type
32
- if (isnested) {
33
- str = str + '+';
34
- }
35
- return str + type + '*';
36
- };
37
-
38
- const localToUsfmActions = {
39
- startDocument: [
40
- {
41
- description: 'Set up environment',
42
- test: () => true,
43
- action: ({ context, workspace }) => {
44
- workspace.usfmBits = [''];
45
- workspace.nestedWrapper = 0;
46
-
47
- for (
48
- let [key, value] of
49
- Object.entries(context.document.metadata.document)
50
- .filter(kv => !['tags', 'properties', 'bookCode', 'cl'].includes(kv[0]))
51
- ) {
52
- workspace.usfmBits.push(`\\${oneifyTag(key)} ${value}\n`);
53
- };
54
- },
55
- },
56
- ],
57
- blockGraft: [
58
- {
59
- description: 'Follow block grafts',
60
- test: ({ context }) => ['title', 'heading', 'introduction'].includes(context.sequences[0].block.subType),
61
- action: (environment) => {
62
- let contextSequence = environment.context.sequences[0];
63
- let chapterValue = environment.config.report[contextSequence.block.blockN.toString()];
64
- const target = contextSequence.block.target;
65
-
66
- if (chapterValue && contextSequence.type === 'main') {
67
- environment.workspace.usfmBits.push(`\n\\c ${chapterValue}\n`);
68
- }
69
-
70
- if (target) {
71
- environment.context.renderer.renderSequenceId(environment, target);
72
- }
73
- },
74
- },
75
- ],
76
- inlineGraft: [
77
- {
78
- description: 'Follow inline grafts',
79
- test: () => true,
80
- action: (environment) => {
81
- const target = environment.context.sequences[0].element.target;
82
-
83
- if (target) {
84
- environment.context.renderer.renderSequenceId(environment, target);
85
- }
86
- },
87
- },
88
- ],
89
- startParagraph: [
90
- {
91
- description: 'Output footnote paragraph tag (footnote)',
92
- test: ({ context }) => (context.sequences[0].block.subType === 'usfm:f' && context.sequences[0].type === 'footnote')
93
- || (context.sequences[0].block.subType === 'usfm:x' && context.sequences[0].type === 'xref'),
94
- action: ({ context, workspace }) => {
95
- workspace.nestedWrapper = 0;
96
- let contextSequence = context.sequences[0];
97
- workspace.usfmBits.push(`\\${oneifyTag(contextSequence.block.subType.split(':')[1])} `);
98
- },
99
- },
100
- {
101
- description: 'Output footnote note_caller tag (footnote)',
102
- test: ({ context }) => context.sequences[0].block.subType === 'usfm:f' || context.sequences[0].block.subType === 'usfm:x',
103
- action: ({ workspace }) => {
104
- workspace.nestedWrapper = 0;
105
- },
106
- },
107
- {
108
- description: 'Output paragraph tag (main)',
109
- test: () => true,
110
- action: ({
111
- context, workspace, config,
112
- }) => {
113
- workspace.nestedWrapper = 0;
114
- let contextSequence = context.sequences[0];
115
- let chapterValue = config.report[contextSequence.block.blockN.toString()];
116
-
117
- if (chapterValue && contextSequence.type === 'main') {
118
- workspace.usfmBits.push(`\n\\c ${chapterValue}\n`);
119
- }
120
- workspace.usfmBits.push(`\n\\${oneifyTag(contextSequence.block.subType.split(':')[1])}\n`);
121
- },
122
- },
123
- ],
124
- endParagraph: [
125
- {
126
- description: 'Output footnote paragraph tag (footnote)',
127
- test: ({ context }) => (context.sequences[0].block.subType === 'usfm:f' && context.sequences[0].type === 'footnote')
128
- || (context.sequences[0].block.subType === 'usfm:x' && context.sequences[0].type === 'xref'),
129
- action: ({ context, workspace }) => {
130
- let contextSequence = context.sequences[0];
131
- workspace.usfmBits.push(`\\${oneifyTag(contextSequence.block.subType.split(':')[1])}*`);
132
- },
133
- },
134
- {
135
- description: 'Output footnote note_caller tag (footnote)',
136
- test: ({ context }) => context.sequences[0].block.subType === 'usfm:f' || context.sequences[0].block.subType === 'usfm:x',
137
- action: () => {
138
- },
139
- },
140
- {
141
- description: 'Output nl',
142
- test: () => true,
143
- action: ({ workspace }) => {
144
- workspace.usfmBits.push(`\n`);
145
- },
146
- },
147
- ],
148
- startMilestone: [
149
- {
150
- description: 'Output start milestone',
151
- test: () => true,
152
- action: ({ context, workspace }) => {
153
- let contextSequenceElement = context.sequences[0].element;
154
- let newStartMileStone = buildMilestone(contextSequenceElement.atts, oneifyTag(contextSequenceElement.subType.split(':')[1]));
155
- workspace.usfmBits.push(newStartMileStone);
156
- },
157
- },
158
- ],
159
- endMilestone: [
160
- {
161
- description: 'Output end milestone',
162
- test: () => true,
163
- action: ({ context, workspace }) => {
164
- workspace.usfmBits.push(`\\${oneifyTag(context.sequences[0].element.subType.split(':')[1])}-e\\*`);
165
- },
166
- },
167
- ],
168
- text: [
169
- {
170
- description: 'Output text',
171
- test: () => true,
172
- action: ({ context, workspace }) => {
173
- const text = context.sequences[0].element.text;
174
- workspace.usfmBits.push(text);
175
- },
176
- },
177
- ],
178
- mark: [
179
- {
180
- description: 'Output chapter or verses',
181
- test: () => true,
182
- action: ({ context, workspace }) => {
183
- const element = context.sequences[0].element;
184
-
185
- if (element.subType === 'verses') {
186
- workspace.usfmBits.push(`\n\\v ${element.atts['number']}\n`);
187
- }
188
- },
189
- },
190
- ],
191
- endSequence: [
192
- {
193
- description: 'Output \\cl',
194
- test: ({ context }) => context.document.metadata.document.cl && context.sequences[0].type === 'title',
195
- action: ({ context, workspace }) => {
196
- workspace.usfmBits.push(`\n\\cl ${context.document.metadata.document.cl}\n`);
197
- },
198
- },
199
- ],
200
- startWrapper: [
201
- {
202
- description: 'Output start tag',
203
- test: () => true,
204
- action: ({ workspace, context }) => {
205
- let contextSequence = context.sequences[0];
206
-
207
- // handle nested wrappers : https://ubsicap.github.io/usfm/characters/nesting.html
208
- if (workspace.nestedWrapper > 0) {
209
- workspace.usfmBits.push(`\\+${oneifyTag(contextSequence.element.subType.split(':')[1])} `);
210
- } else {
211
- workspace.usfmBits.push(`\\${oneifyTag(contextSequence.element.subType.split(':')[1])} `);
212
- }
213
- workspace.nestedWrapper += 1;
214
- },
215
- },
216
- ],
217
- endWrapper: [
218
- {
219
- description: 'Output end tag',
220
- test: ({ context }) => !['fr', 'fq','fqa','fk','fl','fw','fp', 'ft', 'xo', 'xk', 'xq', 'xt', 'xta']
221
- .includes(context.sequences[0].element.subType.split(':')[1]),
222
- action: ({ workspace, context }) => {
223
- workspace.nestedWrapper -= 1;
224
- let contextSequence = context.sequences[0];
225
- let subType = contextSequence.element.subType.split(':')[1];
226
- let isNested = workspace.nestedWrapper > 0;
227
-
228
- if (subType === 'w') {
229
- let newEndW = buildEndWrapper(contextSequence.element.atts, oneifyTag(subType), isNested);
230
- workspace.usfmBits.push(newEndW);
231
- } else {
232
- // handle nested wrappers : https://ubsicap.github.io/usfm/characters/nesting.html
233
- if (isNested) {
234
- workspace.usfmBits.push(`\\+${oneifyTag(contextSequence.element.subType.split(':')[1])}*`);
235
- } else {
236
- workspace.usfmBits.push(`\\${oneifyTag(contextSequence.element.subType.split(':')[1])}*`);
237
- }
238
- }
239
- },
240
- },
241
- {
242
- description: 'Do NOT output end tag',
243
- test: () => true,
244
- action: ({ workspace }) => {
245
- workspace.nestedWrapper -= 1;
246
- },
247
- },
248
- ],
249
- endDocument: [
250
- {
251
- description: 'Build output',
252
- test: () => true,
253
- action: ({ workspace, output }) => {
254
- output.usfm = workspace.usfmBits.join('').replace(/(\s*)\n(\s*)/gm, '\n');
255
- },
256
- },
257
- ],
258
- };
259
-
260
- const perf2usfmCode = function ({ perf, report }) {
261
- const cl = new PerfRenderFromJson({ srcJson: perf, actions: localToUsfmActions });
262
- const output = {};
263
-
264
- cl.renderDocument({
265
- docId: '', config: { report }, output,
266
- });
267
- return { usfm: output.usfm };
268
- };
269
-
270
- const perf2usfm = {
271
- name: 'perf2usfm',
272
- type: 'Transform',
273
- description: 'PERF=>USFM',
274
- inputs: [
275
- {
276
- name: 'perf',
277
- type: 'json',
278
- source: '',
279
- },
280
- {
281
- name: 'report',
282
- type: 'json',
283
- source: '',
284
- },
285
- ],
286
- outputs: [
287
- {
288
- name: 'usfm',
289
- type: 'text',
290
- },
291
- ],
292
- code: perf2usfmCode,
293
- };
294
- module.exports = perf2usfm;
@@ -1,251 +0,0 @@
1
- const { utf8ByteArrayToString, stringToUtf8ByteArray } = require('utf8-string-bytes');
2
- const base64 = require('base64-js');
3
-
4
- const checkNum = (n, func, field) => {
5
- if (typeof n !== 'number') {
6
- throw new Error(`Argument ${field} of ${func} should be a number, not '${n}' (${typeof n})`);
7
- }
8
- };
9
-
10
- class ByteArray {
11
- constructor(initialArraySize, initialLength) {
12
- initialArraySize = initialArraySize || 64;
13
- initialLength = initialLength || 0;
14
- this.growMax = 1024 * 16;
15
- this.length = initialLength;
16
- this.byteArray = new Uint8Array(initialArraySize);
17
- }
18
-
19
- byte(n) {
20
- checkNum(n, 'byte', 'n');
21
-
22
- if (n > this.length - 1) {
23
- throw Error(`Attempt to read byte ${n} of ByteArray of length ${this.length}`);
24
- }
25
- return this.byteArray[n];
26
- }
27
-
28
- bytes(n, l) {
29
- checkNum(n, 'bytes', 'n');
30
- checkNum(l, 'bytes', 'l');
31
-
32
- if ((n + l) > this.length) {
33
- throw Error(`Attempt to read ${l} bytes from start ${n} of ByteArray of length ${this.length}`);
34
- }
35
- return this.byteArray.subarray(n, n + l);
36
- }
37
-
38
- setByte(n, v) {
39
- checkNum(n, 'setByte', 'n');
40
- checkNum(v, 'setByte', 'v');
41
-
42
- if (n > this.length - 1) {
43
- throw Error(`Attempt to set byte ${n} of ByteArray of length ${this.length}`);
44
- }
45
-
46
- if (typeof (v) !== 'number' || v < 0 || v > 255) {
47
- throw Error(`Expected value 0-255 when setting ByteArray, found ${v}`);
48
- }
49
- this.byteArray[n] = v;
50
- }
51
-
52
- setBytes(n, v) {
53
- checkNum(n, 'setBytes', 'n');
54
-
55
- if ((n + v.length) > this.length) {
56
- throw Error(`Attempt to set ${v.length} bytes from start ${n} of ByteArray of length ${this.length}`);
57
- }
58
- this.byteArray.set(v, n);
59
- }
60
-
61
- pushByte(v) {
62
- if (typeof (v) !== 'number' || v < 0 || v > 255) {
63
- throw Error(`Expected value 0-255 when pushing to ByteArray, found ${v}`);
64
- }
65
-
66
- if (this.length === this.byteArray.length) {
67
- this.grow();
68
- }
69
- this.byteArray[this.length] = v;
70
- this.length++;
71
- }
72
-
73
- grow(minNewSize) {
74
- const newBytes = new Uint8Array(
75
- Math.max(
76
- minNewSize || 0,
77
- this.byteArray.length + (
78
- Math.min(
79
- this.growMax,
80
- Math.max(
81
- 16,
82
- this.byteArray.length,
83
- ),
84
- )
85
- ),
86
- ),
87
- );
88
- newBytes.set(this.byteArray);
89
- this.byteArray = newBytes;
90
- }
91
-
92
- trim() {
93
- const newBytes = new Uint8Array(this.length);
94
- newBytes.set(this.byteArray.subarray(0, this.length));
95
- this.byteArray = newBytes;
96
- }
97
-
98
- pushBytes(v) {
99
- for (const ve of v) {
100
- this.pushByte(ve);
101
- }
102
- }
103
-
104
- pushNByte(v) {
105
- checkNum(v, 'pushNByte', 'v');
106
-
107
- // Low byte(s) first
108
- if (typeof (v) !== 'number' || v < 0) {
109
- throw Error(`Expected positive number in pushNByte, found ${v}`);
110
- }
111
-
112
- if (v < 128) {
113
- this.pushByte(v + 128);
114
- } else {
115
- const modulo = v % 128;
116
- this.pushByte(modulo);
117
- this.pushNByte(v >> 7);
118
- }
119
- }
120
-
121
- pushNBytes(vArray) {
122
- for (const v of vArray) {
123
- try {
124
- this.pushNByte(v);
125
- } catch (err) {
126
- throw Error(`Error from pushNByte, called as pushNBytes(${JSON.stringify(vArray)})`);
127
- }
128
- }
129
- }
130
-
131
- nByte(n) {
132
- checkNum(n, 'nByte', 'n');
133
-
134
- if (n > this.length - 1) {
135
- throw Error(`Attempt to read nByte ${n} of ByteArray of length ${this.length}`);
136
- }
137
-
138
- const v = this.byteArray[n];
139
-
140
- if (v > 127) {
141
- return v - 128;
142
- } else {
143
- return v + (128 * this.nByte(n + 1));
144
- }
145
- }
146
-
147
- nBytes(n, nValues) {
148
- checkNum(n, 'nBytes', 'n');
149
- checkNum(nValues, 'nBytes', 'nValues');
150
- const ret = [];
151
-
152
- while (nValues > 0) {
153
- let done = false;
154
- let currentValue = 0;
155
- let multiplier = 1;
156
-
157
- do {
158
- if (n > this.length - 1) {
159
- throw Error(`Attempt to read nByte ${n} of ByteArray of length ${this.length} in nBytes(${n}, ${nValues})`);
160
- }
161
-
162
- const v = this.byteArray[n];
163
-
164
- if (v > 127) {
165
- currentValue += ((v - 128) * multiplier);
166
- ret.push(currentValue);
167
- currentValue = 0;
168
- done = true;
169
- } else {
170
- currentValue += (v * multiplier);
171
- multiplier *= 128;
172
- }
173
- n++;
174
- } while (!done);
175
- nValues--;
176
- }
177
- return ret;
178
- }
179
-
180
- nByteLength(v) {
181
- checkNum(v, 'nByteLength', 'v');
182
-
183
- if (v >= 128 ** 4) {
184
- throw new Error('> 4 bytes found in nByteLength');
185
- }
186
-
187
- let ret = 1;
188
-
189
- while (v > 127) {
190
- v = v >> 7;
191
- ret += 1;
192
- }
193
- return ret;
194
- }
195
-
196
- pushCountedString(s) {
197
- const sA = stringToUtf8ByteArray(s);
198
- this.pushByte(sA.length);
199
- this.pushBytes(sA);
200
- }
201
-
202
- countedString(n) {
203
- checkNum(n, 'countedString', 'n');
204
- const sLength = this.byte(n);
205
- return utf8ByteArrayToString(this.bytes(n + 1, sLength));
206
- }
207
-
208
- clear() {
209
- this.byteArray.fill(0);
210
- this.length = 0;
211
- }
212
-
213
- base64() {
214
- return base64.fromByteArray(this.byteArray);
215
- }
216
-
217
- fromBase64(s) {
218
- this.byteArray = base64.toByteArray(s);
219
- this.length = this.byteArray.length;
220
- }
221
-
222
- deleteItem(n) {
223
- checkNum(n, 'deleteItem', 'n');
224
- const itemLength = this.byte(n) & 0x0000003F;
225
- this.length -= itemLength;
226
-
227
- if (this.length > n) {
228
- const remainingBytes = this.byteArray.slice(n + itemLength);
229
- this.byteArray.set(remainingBytes, n);
230
- }
231
- }
232
-
233
- insert(n, iba) {
234
- checkNum(n, 'insert', 'n');
235
- const insertLength = iba.length;
236
- const newLength = this.length + insertLength;
237
-
238
- if (newLength >= (this.byteArray.length + insertLength)) {
239
- this.grow(newLength);
240
- }
241
-
242
- if (n < newLength) {
243
- const displacedBytes = this.byteArray.slice(n, this.length);
244
- this.byteArray.set(displacedBytes, n + insertLength);
245
- }
246
- this.byteArray.set(iba.byteArray.slice(0, iba.length), n);
247
- this.length = newLength;
248
- }
249
- }
250
-
251
- module.exports = ByteArray;
@@ -1,117 +0,0 @@
1
- const ptBookArray = [
2
- { code: 'GEN', categories:['ot', 'pentateuch'] },
3
- { code: 'EXO', categories:['ot', 'pentateuch'] },
4
- { code: 'LEV', categories:['ot', 'pentateuch'] },
5
- { code: 'NUM', categories:['ot', 'pentateuch'] },
6
- { code: 'DEU', categories:['ot', 'pentateuch'] },
7
- { code: 'JOS', categories:['ot', 'history'] },
8
- { code: 'JDG', categories:['ot', 'history'] },
9
- { code: 'RUT', categories:['ot', 'history'] },
10
- { code: '1SA', categories:['ot', 'history'] },
11
- { code: '2SA', categories:['ot', 'history'] },
12
- { code: '1KI', categories:['ot', 'history'] },
13
- { code: '2KI', categories:['ot', 'history'] },
14
- { code: '1CH', categories:['ot', 'history'] },
15
- { code: '2CH', categories:['ot', 'history'] },
16
- { code: 'EZR', categories:['ot', 'history'] },
17
- { code: 'NEH', categories:['ot', 'history'] },
18
- { code: 'EST', categories:['ot', 'history'] },
19
- { code: 'JOB', categories:['ot', 'wisdom'] },
20
- { code: 'PSA', categories:['ot', 'wisdom'] },
21
- { code: 'PRO', categories:['ot', 'wisdom'] },
22
- { code: 'ECC', categories:['ot', 'wisdom'] },
23
- { code: 'SNG', categories:['ot', 'wisdom'] },
24
- { code: 'ISA', categories:['ot', 'prophecy'] },
25
- { code: 'JER', categories:['ot', 'prophecy'] },
26
- { code: 'LAM', categories:['ot', 'prophecy'] },
27
- { code: 'EZK', categories:['ot', 'prophecy'] },
28
- { code: 'DAN', categories:['ot', 'prophecy'] },
29
- { code: 'HOS', categories:['ot', 'prophecy'] },
30
- { code: 'JOL', categories:['ot', 'prophecy'] },
31
- { code: 'AMO', categories:['ot', 'prophecy'] },
32
- { code: 'OBA', categories:['ot', 'prophecy'] },
33
- { code: 'JON', categories:['ot', 'prophecy'] },
34
- { code: 'MIC', categories:['ot', 'prophecy'] },
35
- { code: 'NAM', categories:['ot', 'prophecy'] },
36
- { code: 'HAB', categories:['ot', 'prophecy'] },
37
- { code: 'ZEP', categories:['ot', 'prophecy'] },
38
- { code: 'HAG', categories:['ot', 'prophecy'] },
39
- { code: 'ZEC', categories:['ot', 'prophecy'] },
40
- { code: 'MAL', categories:['ot', 'prophecy'] },
41
- { code: 'MAT', categories:['nt', 'gospel', 'synoptic'] },
42
- { code: 'MRK', categories:['nt', 'gospel', 'synoptic'] },
43
- { code: 'LUK', categories:['nt', 'gospel', 'synoptic'] },
44
- { code: 'JHN', categories:['nt', 'gospel'] },
45
- { code: 'ACT', categories:['nt', 'gospel'] },
46
- { code: 'ROM', categories:['nt', 'epistle'] },
47
- { code: '1CO', categories:['nt', 'epistle'] },
48
- { code: '2CO', categories:['nt', 'epistle'] },
49
- { code: 'GAL', categories:['nt', 'epistle'] },
50
- { code: 'EPH', categories:['nt', 'epistle'] },
51
- { code: 'PHP', categories:['nt', 'epistle'] },
52
- { code: 'COL', categories:['nt', 'epistle'] },
53
- { code: '1TH', categories:['nt', 'epistle'] },
54
- { code: '2TH', categories:['nt', 'epistle'] },
55
- { code: '1TI', categories:['nt', 'epistle'] },
56
- { code: '2TI', categories:['nt', 'epistle'] },
57
- { code: 'TIT', categories:['nt', 'epistle'] },
58
- { code: 'PHM', categories:['nt', 'epistle'] },
59
- { code: 'HEB', categories:['nt', 'epistle'] },
60
- { code: 'JAS', categories:['nt', 'epistle'] },
61
- { code: '1PE', categories:['nt', 'epistle'] },
62
- { code: '2PE', categories:['nt', 'epistle'] },
63
- { code: '1JN', categories:['nt', 'epistle'] },
64
- { code: '2JN', categories:['nt', 'epistle'] },
65
- { code: '3JN', categories:['nt', 'epistle'] },
66
- { code: 'JUD', categories:['nt', 'epistle'] },
67
- { code: 'REV', categories:['nt', 'epistle'] },
68
- { code: 'TOB', categories:['dc'] },
69
- { code: 'JDT', categories:['dc'] },
70
- { code: 'ESG', categories:['dc', 'history'] },
71
- { code: 'WIS', categories:['dc', 'wisdom'] },
72
- { code: 'SIR', categories:['dc', 'wisdom'] },
73
- { code: 'BAR', categories:['dc', 'prophecy'] },
74
- { code: 'LJE', categories:['dc'] },
75
- { code: 'S3Y', categories:['dc'] },
76
- { code: 'SUS', categories:['dc'] },
77
- { code: 'BEL', categories:['dc'] },
78
- { code: '1MA', categories:['dc'] },
79
- { code: '2MA', categories:['dc'] },
80
- { code: '3MA', categories:['dc'] },
81
- { code: '4MA', categories:['dc'] },
82
- { code: '1ES', categories:['dc'] },
83
- { code: '2ES', categories:['dc'] },
84
- { code: 'MAN', categories:['dc'] },
85
- { code: 'PS2', categories:['dc'] },
86
- { code: 'ODA', categories:['dc'] },
87
- { code: 'PSS', categories:['dc'] },
88
- { code: 'JSA', categories:['dc'] },
89
- { code: 'JDB', categories:['dc'] },
90
- { code: 'TBS', categories:['dc'] },
91
- { code: 'SST', categories:['dc'] },
92
- { code: 'DNT', categories:['dc'] },
93
- { code: 'BLT', categories:['dc'] },
94
- { code: 'EZA', categories:['dc'] },
95
- { code: '5EZ', categories:['dc'] },
96
- { code: '6EZ', categories:['dc'] },
97
- { code: 'DAG', categories:['dc'] },
98
- { code: 'PS3', categories:['dc'] },
99
- { code: '2BA', categories:['dc'] },
100
- { code: 'LBA', categories:['dc'] },
101
- { code: 'JUB', categories:['dc'] },
102
- { code: 'ENO', categories:['dc'] },
103
- { code: '1MQ', categories:['dc'] },
104
- { code: '2MQ', categories:['dc'] },
105
- { code: '3MQ', categories:['dc'] },
106
- { code: 'REP', categories:['dc'] },
107
- { code: '4BA', categories:['dc'] },
108
- { code: 'LAO', categories:['dc'] },
109
- ];
110
-
111
- let ptBooks = {};
112
-
113
- for (const br of ptBookArray.entries()) {
114
- ptBooks[br[1].code] = { ...br[1], position: br[0] };
115
- }
116
-
117
- module.exports = { ptBookArray, ptBooks };
@@ -1,41 +0,0 @@
1
- const xre = require('xregexp');
2
-
3
- const enumStringIndex = (enumSuccinct, str) => {
4
- let pos = 0;
5
- let count = 0;
6
-
7
- while (pos < enumSuccinct.length) {
8
- const stringLength = enumSuccinct.byte(pos);
9
- const enumString = enumSuccinct.countedString(pos);
10
-
11
- if (enumString === str) {
12
- return count;
13
- }
14
- pos += (stringLength + 1);
15
- count += 1;
16
- }
17
- return -1;
18
- };
19
-
20
- const enumRegexIndexTuples = (enumSuccinct, regex) => {
21
- let pos = 0;
22
- let count = 0;
23
- const ret = [];
24
-
25
- while (pos < enumSuccinct.length) {
26
- const stringLength = enumSuccinct.byte(pos);
27
- const enumString = enumSuccinct.countedString(pos);
28
-
29
- if (xre.exec(enumString, xre(regex, 'i'))) {
30
- ret.push([count, enumString]);
31
- }
32
- pos += (stringLength + 1);
33
- count += 1;
34
- }
35
- return ret;
36
- };
37
-
38
- module.exports = {
39
- enumStringIndex,
40
- enumRegexIndexTuples,
41
- };