0.0.24 • Published 9 months ago

versification v0.0.24

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

versification

A library for parsing Paratext's vrs files.

license builds.sr.ht status

Installation

npm install --save versification

Usage

The library has two main classes Versification and VerseRef. Versification parses a Paratext versification file (.vrs), which can be used to convert a VerseRef from one versification to another.

// Example usage, creating a VerseRef with Versification.

import Versification, { VerseRef } from 'versification';

const testVersification = `
# Versification  "English"
GEN 1:31 2:25 3:24 4:26 5:32 6:22
PSA 1:6 2:12 3:8
PSA 3:0-8 = PSA 3:1-9
`;


const myReducedSizeEnglishVersification = new Versification(testVersification);

const myVerseRef = VerseRef.parse('PSA 3:1', myReducedSizeEnglishVersification);
// Example changing a VerseRef versification.

import Versification, { VerseRef } from 'versification';

const testEnglishVersification = `
# Versification  "English"
GEN 1:31 2:25 3:24 4:26 5:32 6:22
PSA 1:6 2:12 3:8
PSA 3:0-8 = PSA 3:1-9
`;

const testOriginalVersification = `
# Versification  "Original"
GEN 1:31 2:25 3:24 4:26 5:32 6:22
PSA 1:6 2:12 3:9
`;

const engV = new Versification(testEnglishVersification);
const orgV = new Versification(testOriginalVersification);

const myEnglishVerseRef = VerseRef.parse('PSA 3:1', engV);

const myOriginalVerseRef = orgV.changeVersification(myEnglishVerseRef);

// Outputs 'PSA 3:2'
console.log(myOriginalVerseRef.toString()); 

Versification

methoddescriptionreturn type
constructor(string)Create Versification from vrs file contents
static nameToFileName(string)Helper function to map versification name to Paratext vrs file name. EG "original" -> "org"string
static bookIdToNumber(string)Helper function to convert a book id to its index number. EG "GEN" => 1number
booksReturns 1 based array showing verses per chapter. eg. indexing result with 1 would return then number of verses in GEN 2.number
mappingsReturns versification specific mappings. First VerseRef 0 is from, second 1 is to.VerseRef,VerseRef
excludedVerses(book? number, chapter? number)return number is bbbcccvvv. Optionally filter results by book + chapter number.Set<number>
verseSegments(book? number, chapter? numbernumber is bbbcccvvv. Optionally filter results by book + chapter number.Record<number, string[]>
changeVersification(VerseRef)Convert a VerseRef to this versification. (applying any mappings)VerseRef
equals(Versification)Compare Versification (by name)boolean

VerseRef

methoddescriptionreturn type
static parse(string, ?Versification)Create a VerseRef from a verse ref string and optional versificationVerseRef
static fromBookIdChapterVerse(string, number, number, ?Versification)Create a verseRef from Book Id (eg. 'GEN') and chapter and verse numbers, and optional versification.VerseRef
static fromBookChapterVerse(number, number, number, ?Versification)Create a verseRef from book, chapter and verse numbers, and optional versification.VerseRef
static frombcv(number or string, ?Versification)Create a verseRef from a bbbcccvvv and optional versification.VerseRef
static toBook(number bbbcccvvv)extract book number from bbbcccvvvnumber
static toChapter(number bbbcccvvv)extract chapter number from bbbcccvvvnumber
static toVerse(number bbbcccvvv)extract verse number from bbbcccvvvnumber
bookReturns book IDstring
chapterReturns chapter number as stringstring
verseReturns verse as string. (can be a verse range or a split verse)string
verseNumReturns verse as number. (if range will be the first verse in range)number
verseNumEndundefined if VerseRef is not a range.number or undefined
segmentundefined if VerseRef is not a split verse.string or undefined
versificationReturn the Versification for this VerseRef. If not specified will return undefined.Versification or undefined
changeVersification(Versification)Update this VerseRef to new versification. (applying any mappings)
bbbcccvvvA number encoded with book, chapter + verse.number
equals(VerseRef)Compare Verse refboolean
isDefinedByVersificationreturns true if verseRef is defined by its versification or versification not defined.boolean
toStringReturns a verse ref stringstring
0.0.20

11 months ago

0.0.21

11 months ago

0.0.22

10 months ago

0.0.23

10 months ago

0.0.24

9 months ago

0.0.15

12 months ago

0.0.16

12 months ago

0.0.17

12 months ago

0.0.18

12 months ago

0.0.19

11 months ago

0.0.14

12 months ago

0.0.13

12 months ago

0.0.12

12 months ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago