Skip to content
This repository has been archived by the owner on Mar 19, 2020. It is now read-only.

Custom solution of chapter-and-verse for Heb12

License

Notifications You must be signed in to change notification settings

heb12/chapter-and-verse

 
 

Repository files navigation

chapter-and-verse

build coverage npm dependencies downloads

Given a bible reference, validates it and returns an object with book, chapter, verse and more


Introduction

Throw a bible reference at chapter-and-verse and, if valid, it returns a detailed JSON object for that reference.

If invalid, it returns a JSON object with the reason for failure.

chapter-and-verse understands all common bible book abbreviations and has its own built-in book identification algorithm.

It is useful when building biblical reference based URLs, for integrating with bible APIs and for validating raw user input.

chapter-and-verse is written by a professional developer, has 100% unit test coverage and is ready for production use.

All our biblical data has been triple checked to ensure reliability.

chapter-and-verse works in Node code and browsers.


Supported reference formats

chapter-and-verse supports all the following reference formats:

format example notes
book Genesis
book chapter Genesis 5 multi chapter books
book verse Obadiah 3 single chapter books
book verses Obadiah 3-5 single chapter books only
book chapter:verse Genesis 5:1
book chapter:verses Genesis 5:1-4

Usage

npm install --save chapter-and-verse

Usage:

const chapterAndVerse = require('chapter-and-verse')
let cv = chapterAndVerse('Dan 4:1-3')

And cv now looks like:

{
  "book": {
    "id": "Dan",
    "name": "Daniel",
    "testament": "O",
    "start": "dan",
    "abbr": ["da", "dn"],
    "chapters": 12,
    "versesPerChapter": [21, 49, 30, 37, 31, 28, 28, 27, 27, 21, 45, 13]
  },
  "success": true,
  "reason": "matches book.id",
  "chapter": 4,
  "from": 1,
  "to": 3
}

To validate a reference:

const chapterAndVerse = require('chapter-and-verse')
const ref = 'Dan 4:1-3'
let cv = chapterAndVerse(ref)
if (cv.success === true) {
  console.log(ref + ' is valid')
}
if (cv.success === false) {
  console.log(ref + ' is invalid because ' + cv.reason)
}

For more information see the Validation section.


Browser usage

npm install --save chapter-and-verse

Add a script tag in head:

<script src="node_modules/chapter-and-verse/chapterAndVerse.js"></script>

Then use as follows:

<script>
  const cv = chapterAndVerse('Gn')
  console.log(cv.book.name) // Genesis
</script>

You can validate a reference as described in the Usage section.


Methods

For a valid reference a number of methods are available.

Use cv.toString() and cv.toShortString() as follows:

cv = chapterAndVerse('Dan 4:1-3')
cv.toString() // returns 'Daniel 4:1-3'
cv.toShortString() // returns 'Daniel 4:1-3' .. no difference because Daniel is a multi chapter book

cv = chapterAndVerse('ob 1-3')
cv.toString() // returns 'Obadiah 1:1-3'
cv.toShortString() // returns 'Obadiah 1-3' .. difference because Obadiah is a single chapter book

cv.getType() returns one of 'book', 'chapter', 'verses' or 'verse'

Finally cv.toSimpleObject() provides access to a flat object containing only essential data:

cv = chapterAndVerse('exo 33:7-12')
cv.toSimpleObject()

Which returns:

{
  "type": "verses",
  "asString": "Exodus 33:7-12",
  "asShortString": "Exodus 33:7-12",
  "bookId": "Exod",
  "bookName": "Exodus",
  "testament": "O",
  "chapter": 33,
  "from": 7,
  "to": 12
}

Validation

chapter-and-verse returns a failure object if it cannot resolve the biblical reference:

{
  "book": {},
  "success": false,
  "reason": "book does not exist"
}

This happens when the:

chapter-and-verse does NOT recognise apocryphal books.


Accuracy of biblical data

All our chapter and verse data has been "triple checked" as follows:

(1) The data was entered manually and manually checked.

(2) We then ran code against our data, ensuring verse and chapter totals were correct.

(3) Finally, we programmatically tested our data against other online sources to ensure "total agreement".


Translation specifics

Certain verses only exist in certain translations.

  • 3 John 15

chapter-and-verse reports 3 John 15 as valid. However, this verse does not exist in the KJV wherein it has been merged with 3 John 14.

This is the only chapter-and-verse discrepancy with the KJV.

Compare 3 John 14-15 ESV with 3 John 14 KJV

  • Omitted verses

In modern English translations, certain New Testament verses, which exist in the KJV, have been omitted.

For example Matthew 17:21 ESV does not exist whereas Matthew 17:21 KJV does exist.

chapter-and-verse treats all omitted verses as valid and is not concerned with translation specifics.

For an in-depth discussion see omitted verses


Author says

The Lord bless you and keep you;

the Lord make his face to shine upon you and be gracious to you;

the Lord lift up his countenance upon you and give you peace.

Numbers 6:24-26 ESV




About

Custom solution of chapter-and-verse for Heb12

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.1%
  • HTML 1.9%