codexparser 0.1.22 → 0.1.23

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/CodexParser.js +32 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "This is a Javascript Bible parser and text scanner. It will search through texts and collate all scripture references into an array and parse them into objects, and it will parse passages into objects by book, chapter, verse, and testament. ",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -366,18 +366,41 @@ class CodexParser {
366
366
  }
367
367
 
368
368
  versification() {
369
- for (let i = 0; i < this.passages.length; i++) {
370
- const passage = this.passages[i]
369
+ this.passages.forEach((passage) => {
371
370
  const hasVersification = this.versificationDifferences[passage.book]
372
- for (let j = 0; j < passage.passages.length; j++) {
373
- const subPassage = passage.passages[j]
371
+
372
+ passage.passages.forEach((subPassage) => {
373
+ // Apply general versification differences
374
374
  if (hasVersification) {
375
- if (this.versificationDifferences[passage.book][subPassage.chapter + ":" + subPassage.verse])
376
- subPassage.versification =
377
- this.versificationDifferences[passage.book][subPassage.chapter + ":" + subPassage.verse]
375
+ const key = `${subPassage.chapter}:${subPassage.verse}`
376
+ if (this.versificationDifferences[passage.book][key]) {
377
+ subPassage.versification = this.versificationDifferences[passage.book][key]
378
+ }
378
379
  }
379
- }
380
- }
380
+
381
+ // Handle specific version adjustments for "lxx" or "mt"
382
+ if (passage.version) {
383
+ const versionAbbreviation = passage.version.abbreviation
384
+ const versionType =
385
+ versionAbbreviation === "lxx" ? "lxx" : versionAbbreviation === "mt" ? "mt" : null
386
+
387
+ if (versionType) {
388
+ const versionReference = `${subPassage.chapter}:${subPassage.verse}`
389
+
390
+ // Look for matching versification based on the version type (lxx or mt)
391
+ for (const versification in this.versificationDifferences[passage.book]) {
392
+ if (
393
+ this.versificationDifferences[passage.book][versification][versionType] ===
394
+ versionReference
395
+ ) {
396
+ subPassage.versification = this.versificationDifferences[passage.book][versification]
397
+ break // Break once a match is found
398
+ }
399
+ }
400
+ }
401
+ }
402
+ })
403
+ })
381
404
  }
382
405
 
383
406
  /**