chapter-and-verse
Given a bible reference returns an object with the bible book, chapter, verse and more
Introduction
Throw a bible reference at chapter-and-verse
and it returns a detailed JSON object for that reference.
chapter-and-verse
understands all common bible book abbreviations and more.
It is particularly useful when formulating bible reference based URLs and for dealing with complex bible APIs / raw user input.
chapter-and-verse
handles all the following reference formats:
format | example | notes |
---|
book | Genesis | |
book chapter | Genesis 5 | |
book verse | Obadiah 3 | single chapter books only |
book verses | Obadiah 3-5 | single chapter books only |
book chapter:verse | Genesis 5:1 | |
book chapter:verses | Genesis 5:1-4 | |
chapter-and-verse
is written by a professional developer, has 100% unit test coverage and is ready for production use.
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
},
"reason": "matches book.id",
"chapter": 4,
"from": 1,
"to": 3,
"range": [1, 2, 3]
}
Methods
Use cv.toString()
and cv.toShortString()
as follows:
cv = chapterAndVerse('Dan 4:1-3')
cv.toString()
cv.toShortString()
cv = chapterAndVerse('ob 1-3')
cv.toString()
cv.toShortString()
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,
"range": [7, 8, 9, 10, 11, 12]
}
Validation
chapter-and-verse
returns null
if it cannot resolve the biblical reference.
This happens when the:
-
Reference is not in one of the six supported formats above
-
Book cannot be determined from the reference given
-
Chapter number is invalid for the book in question
-
verse from
and verse to
are not in the range 1-176 - see Psalm 119:176 ESV
chapter-and-verse
does NOT return null
if the verse range is invalid for the chapter in question; being beyond the intended scope.
chapter-and-verse
is NOT intended to recognise apocryphal books.
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