codexparser 0.1.33 → 0.1.34

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 +39 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexparser",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
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": {
@@ -703,6 +703,45 @@ class CodexParser {
703
703
  return merged
704
704
  }
705
705
 
706
+ getToc(version = "ESV") {
707
+ // Initialize the table of contents (toc)
708
+ const toc = {}
709
+
710
+ // Add Old Testament books and their chapters/verses to toc
711
+ this.bible.old.forEach((book) => {
712
+ if (this.chapterVerses[book]) {
713
+ toc[book] = this.chapterVerses[book]
714
+ }
715
+ })
716
+
717
+ // Add New Testament books and their chapters/verses to toc
718
+ this.bible.new.forEach((book) => {
719
+ if (this.chapterVerses[book]) {
720
+ toc[book] = this.chapterVerses[book]
721
+ }
722
+ })
723
+
724
+ // Merge in single-chapter books if not already in toc
725
+ this.singleChapterBook.forEach((item) => {
726
+ Object.keys(item).forEach((book) => {
727
+ if (!toc[book]) {
728
+ toc[book] = item[book]
729
+ }
730
+ })
731
+ })
732
+
733
+ // Sort the keys of toc by canonical order
734
+ const orderedToc = {}
735
+ const canonicalOrder = [...this.bible.old, ...this.bible.new]
736
+ canonicalOrder.forEach((book) => {
737
+ if (toc[book]) {
738
+ orderedToc[book] = toc[book]
739
+ }
740
+ })
741
+
742
+ return orderedToc
743
+ }
744
+
706
745
  _isValid(passage, reference) {
707
746
  const singleChapterBook = this.singleChapterBook.find((bible) => bible[passage.book])
708
747
  if (!passage.verses) {