0.0.24 • Published 2 years ago
versification v0.0.24
versification
A library for parsing Paratext's vrs files.
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
method | description | return 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" => 1 | number |
books | Returns 1 based array showing verses per chapter. eg. indexing result with 1 would return then number of verses in GEN 2. | number |
mappings | Returns 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? number | number 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
method | description | return type |
---|---|---|
static parse(string, ?Versification) | Create a VerseRef from a verse ref string and optional versification | VerseRef |
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 bbbcccvvv | number |
static toChapter(number bbbcccvvv) | extract chapter number from bbbcccvvv | number |
static toVerse(number bbbcccvvv) | extract verse number from bbbcccvvv | number |
book | Returns book ID | string |
chapter | Returns chapter number as string | string |
verse | Returns verse as string. (can be a verse range or a split verse) | string |
verseNum | Returns verse as number. (if range will be the first verse in range) | number |
verseNumEnd | undefined if VerseRef is not a range. | number or undefined |
segment | undefined if VerseRef is not a split verse. | string or undefined |
versification | Return 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) | |
bbbcccvvv | A number encoded with book, chapter + verse. | number |
equals(VerseRef) | Compare Verse ref | boolean |
isDefinedByVersification | returns true if verseRef is defined by its versification or versification not defined. | boolean |
toString | Returns a verse ref string | string |
0.0.20
2 years ago
0.0.21
2 years ago
0.0.22
2 years ago
0.0.23
2 years ago
0.0.24
2 years ago
0.0.15
2 years ago
0.0.16
2 years ago
0.0.17
2 years ago
0.0.18
2 years ago
0.0.19
2 years ago
0.0.14
2 years ago
0.0.13
2 years ago
0.0.12
2 years ago
0.0.11
2 years ago
0.0.10
2 years ago
0.0.9
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago