npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chapter-and-verse

v3.0.4

Published

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

Downloads

415

Readme

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