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

biblejs

v1.0.0

Published

Normalize bible references, convert them to machine readable formats, query and manipulate them

Downloads

123

Readme

bible.js

bible.js is a JavaScript package for both Node and the browser (via Bower) for handling Bible references. It can:

  • parse textual references into a standard, index based format
  • convert a textual reference to an absolute verse number
  • convert an absolute verse number to its textual reference
  • handle chapter references
  • handle ranges (e.g. John 3:1-16) (WIP)

Installation

node

npm install --save biblejs

Usage

The biblejs module exposes three top level exports:

const Bible = require('biblejs'); let Reference = Bible.Reference // A class representing a single verse or chapter let Range = Bible.Range // A class representing a range of verses let Books = Bible.Books // A reference array containing data on the names and number of chapters/verses for each book in the Bible

Reference

A Reference instance represents a reference to a specific Bible verse, or an entire chapter.

var ref = new Reference("John 3:16");
// returns a Reference instance for "John 3:16"

Instance Methods

isChapter()

Returns true if the reference is to an entire chapter rather than a specific verse

var chapter = new Reference("John 1");
var verse = new Reference("John 1:1");

chapter.isChapter() // true
verse.isChapter() // false

startOf('book|chapter')

Modifies the reference in place (doesn't create a new one!), moving the reference to the start of the book or chapter.

var ref = new Reference("John 3:16");

ref.startOf('chapter').toString() // "John 3:1"
ref.startOf('book').toString() // "John 1:1"

clone()

Create a new Reference object of the same verse. Useful if you want to perform in-place mutations to the Reference (i.e. .startOf()) but want to retain the original reference as well.

toString()

Returns the textual representation of the reference. Right now, this only supports full book names. Future versions will likely include a format argument to determine the format of the returned string (PR's welcome!).

Reference.fromVerseId(1).toString() // "Genesis 1:1"

toVerseId()

Returns the verse id (i.e. the number of the verse if you started from Genesis 1:1 and counted up to it).

var ref = new Reference("Genesis 1:1");
ref.toVerseId() // 1

#toChapterId()

Returns the chapter id (i.e. the number of the chapter if you started from Genesis 1 and counted up to it).

var ref = new Reference("Genesis 7");
ref.toChapterId() // 7

#toBookId()

Returns the book id (i.e. the number of the book if you started from Genesis and counted up to it).

var ref = new Reference("Exodus");
ref.toBookId() // 2

Static Methods

The static methods found on the Reference class are useful for creating References from something other than a string (i.e. a verse or chapter id), as well as some utility methods for performing reference math.

Reference.bookIdFromName(name)

Returns the book id given a book name. Handles most common book abbreviations.

Reference.bookIdFromName("Genesis") // 1
Reference.bookIdFromName("Gen") // 1
Reference.bookIdFromName("Exo") // 2

Reference.bookNameFromId(id)

Get the name of the book of the Bible that matches the given id:

Reference.bookNameFromId(1) // "Genesis"

Reference.fromChapterId(chapterId) {

Parse a chapter id into a reference. A chapter id is the 1-indexed absolute number of the chapter.

Reference.fromChapterId(1) // Genesis 1

Reference.fromVerseId(verseId) {

Parse a verse id into a reference. A verse id is 1-indexed absolute number of the verse (i.e. Genesis 2:1's verse id is 32, because Genesis 1 has 31 verses).

Reference.fromVerseId(1) // Genesis 1:1

Reference.versesInBookId(bookId) {

Get the number of verses in the given book id

// How many verses are in all of Genesis?
Reference.versesInBookId(1) // 1533

Reference.versesInChapterId(chapterId) {

Get the number of verses in the given chapter id

// How many verses are in Genesis 1?
Reference.versesInChapterId(1) // 31

Reference.chaptersInBookId(bookId) {

Get the number of chapters in the given book id

// How many chapters are in Genesis?
Reference.chaptersInBookId(1) // 50

Reference.versesUpToBookId(bookId) {

Get the number of verses up to the start of the given book id

// How many verses are there in all the books before Exodus?
Reference.versesUpToBookId(2) // 1533

Reference.versesUpToChapterId(chapterId) {

Get the number of verses up to the start of the given chapter id

// How many verses are there in all the books before Exodus 2?
Reference.versesUpToChapterId(51) // 1555

Reference.chaptersUpToBookId(bookId) {

Get the number of chapters up to the start of the given book id

// How many chapters are there in all the books before Exodus?
Reference.chaptersUpToBookId(2) // 50

Reference.bookNameFromId(id)

Returns the full book name given a book id.

Reference.bookNameFromId(1) // "Genesis"
Reference.bookNameFromId(2) // "Exodus"

Range

A Range instance represents a reference to a range of Bible verses. Internally, this is represented as to Reference objects that track the start and end of the range of verses.

var start = new Reference('Genesis 1:1');
var start = new Reference('Genesis 2:1');
var range = new Range(start, end);
// returns a Range instance that represents Genesis 1:1-2:1

Instance Methods

distance()

Calculates the "distance" the Range covers. Returns an object that includes the number of verses, chapters, and books in the Range:

var start = new Reference('Genesis 1:1');
var start = new Reference('Exodus 1:1');
var range = new Range(start, end);
range.distance(); // { verses: 1533, chapters: 50, books: 1 }

A book or chapter is consided "in" the range if it's entire contents are. So Genesis 1:1 - Exodus 2:1 only has 1 book in the range, but has 51 chapters in the range (since all of Exodus is not in the range, but all of Exodus 1 is in the range).

Books

This is a reference data array that includes the common names and their variants and abbreviations of each book of the Bible, along with the number of chapters in each book, and the number of verses in each chapter.