codexparser 0.1.3 → 0.1.4

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 +18 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
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": {
@@ -310,6 +310,8 @@ class CodexParser {
310
310
  parsedPassage.passages = this.populate(parsedPassage)
311
311
  })
312
312
 
313
+ parsedPassage.valid = this._isValid(parsedPassage, passage.reference)
314
+
313
315
  return parsedPassage
314
316
  })
315
317
  this.versification()
@@ -344,6 +346,9 @@ class CodexParser {
344
346
 
345
347
  // Helper function to process a parsed passage's verses
346
348
  const processVerses = (chapter, verses, book) => {
349
+ if (!verses) {
350
+ return
351
+ }
347
352
  verses.forEach((verse) => {
348
353
  if (isNaN(verse)) {
349
354
  const [start, end] = verse.split("-").map(Number) // Handle ranges
@@ -428,6 +433,19 @@ class CodexParser {
428
433
  hash,
429
434
  }
430
435
  }
436
+
437
+ _isValid(passage, reference) {
438
+ if (!passage.verses) {
439
+ return {
440
+ error: true,
441
+ code: 101,
442
+ message: {
443
+ chapter_exists: false,
444
+ content: "Possible invalid chapter: " + reference,
445
+ },
446
+ }
447
+ }
448
+ }
431
449
  }
432
450
 
433
451
  module.exports = CodexParser