Constructor interface
We are using a hybrid interface to this lib, you can just require(lib) and call function such as parse, parseOrThrow, etc - or you can construct a new instance with a non standard versification scheme and then call methods of that
Set of arguments that can be passed to represent a formatting scheme
Either a full FormatOptions object describing the options, or a present name such as "osis" for OSIS formatted references
Present name can be combined with :, eg: url:combined to use url formatting, and combine ranges Later presets override earlier presets
For a full list of present names, see FormatPreset
Enumeration of possible format presets
compact
flag to truelowercase
flag to truecombine_ranges
flag to truecomplete_refs
flag to trueOpaque type containing data for use by getIntersection
or intersects
Represents the output of attempting to parse a string containing a Bible reference
Check the status
field to see if the parse succeeded, and then utalize the fields
of ParseResultSuccess and ParseResultFailure as appropriate
Represents an error which was detected during validation
Generates the most compressed representation possible of some set of BibleVerses/BibleRanges by combining adjacent or overlapping ranges into larger ones
For example, an input list of "Gen 1", "Gen 2", "Gen 3", would produce a single BibleRange for "Gen 1-3"
Order of input ranges in unimportant, since this functional will interally call sort first
Counts the total number of verses expressed by a BibleRef
Precomputes data regarding BibleRef list as used by getIntersection
and intersects
This is more performant if you call either of these functions multiple times where one of the two inputs remains constant
Creates a full Versification object from the minimal data set by computing the rest
Converts a "Verse Index" produced by [[toVidex]] back into a JSON BibleVerse
Creates a new array of BibleRefs which represents the intersection between two other sets
Any object with a versification
field
First set of BibleRef instances
Second set of BibleRef instances
Simplified and sorted list of BibleRefs which appear in both input sets. Will return empty array if there are no verses in common between the inputs
Groups a list of references into buckets split by book
Returns list of RefsByBook representing the buckets that the input references have been sorted into. Returns list will be in order from the bucket for the first book to the last book, however the individual references within each bucket will maintain their order relative to the input array - hence input order matters. Pre-sort if desired.
Groups a list of references into buckets split by book, chapter
Returns list of RefsByChapter representing the buckets that the input references have been sorted into. Returns list will be in order from the bucket for the first book to the last book, however the individual references within each bucket will maintain their order relative to the input array - hence input order matters. Pre-sort if desired.
Sorts a list of references into seperate lists for full books, full chapters, and individual verses
For example, Gen, Exo.1, Lev.1.1 would be grouped into the object: { books : [ Gen ], chapters : [ Exo.1 ], verses : [ Lev.1.1 ], }
The books
and chapters
array will contain only BibleRanges, where as verses
will
contain only BibleVerses
The output arrays will be de-deuplicated when multiple inputs would create the same output, and arrays will be sorted into verse order - hence input order is not important
Given a (potentially non-continous) set of BibleRef's, computes the index of some BibleVerse within the set.
For example, given the input set "Revelation 1:1; Exodus 1:2-4; Genesis 10:5" the following verses appear at each index:
The array of input verses you wish to search (aka, the haystack)
The verse whose index you wish to determnine (aka, the needle)
The zero based index at which verse
can be found, or -1 if the verse
does not appear
within the input array
Determines whether two sets of BibleRefs have any verses in common
This is much faster on large data sets than getIntersection
when just a boolean result is
required
Determines if a BibleRef is in fact just a single BibleRange which represents exactly the entirety of a single book - no more, no less
Boolean representing decision
Determines if a BibleRef is in fact just a single BibleRange which represents exactly the entirety of a single chapter - no more, no less
Boolean representing decision
Returns an iterator that traverses over the objects that would have been
returned by splitByVerse
Creates a BibleRange representing either an entire book, or an entire chapter
Any object with a versification
field
Given a BibleRef, returns a new BibleRef which represents the range of verses making up the next book after the book containing the last verse in the input range
BibleRef or null if there is no next book (IE: input is revelation)
Given a BibleRef, returns a new BibleRef which represents the next chapter after the last verse in the input ref.
If true, will not cross book boundaries to find another chapter
BibleRef or null if there is no next chapter
Given a BibleRef, returns a new BibleVerse which represents the next verse after the last verse in the input ref
If set, will not cross book boundaries to find another verse
If set, will not cross chapter boundaries to find another verse
Parses a string which may (or may not) represent a BibleRef and returns a ParseResult representing whether the parse was successful, and if so what value was obtained.
Examples of valid input strings include:
Book references (returns (list of) range(s) representing entire book):
Chapter references (returns (list of) range(s) representing entire chapters):
Verse References (represents a single verse):
Verse Ranges (continous blocks of verses, can cross chapter/book boundaries):
Complex sets/combinations:
Instance of BibleRefLib (includes the versification to use)
The string to parse
Parses the name of a book and returns either a string containing the USFM book id
or null
if the book name was not recognised
Instance of BibleRefLib (includes the versification to use)
The string to parse
If the input string is known to be in syntax as written by format function using the 'url' preset, parseUrlEncoded is equivalent to this function but runs ~20x faster
Instance of BibleRefLib (includes the versification to use)
The string to parse
Function to parse data written using format with the 'url' preset This operates ~20x faster than the generic parser and guarantied to produce the exact same output as standard parseOrThrow on good input. Behaviour is undefined on bad input - some checks are omitted for increased performance which may cause this function to return garbage output when parseOrThrow would have thrown
For reference, a 5.5kb url-encoded BibleRef string takes 1.5ms to parse with this function, or 30ms to parse with the generic parser. The equivalent JSON representation of the data is 72kb, but can be parsed in ~0.7ms using the native JSON.parse function
Given a BibleRef, returns a new BibleRef which represents the range of verses making up the book before the book containing the first verse in the input range
BibleRef or null if there is no previous book (IE: input is genesis)
Returns BibleRef representing the range of verses making up the chapter BEFORE the first verse of the input ref
If true, will not cross book boundaries to find another chapter
BibleRef or null if there is no previous chapter
Given a BibleRef, returns a new BibleVerse which represents the verse preceeding the first verse in the input ref
If set, will not cross book boundaries to find another verse
If set, will not cross chapter boundaries to find another verse
Takes an array of BibleRef instances and sorts them into order as per the versification scheme in use, from the BibleRef which appears first, to the one which apears last
Splits an array of ranges such that any input range spanning multiple books is subdivided into multiple smaller ranges, one for each book
The list of refs to be split
If set then even single verses will be represented as ranges of length 1, ensuring all returned objects have the same schema
Splits an array of ranges such that any input range spanning multiple chapters is subdivided into multiple smaller ranges, one for each chapter
The list of refs to be split
If set then even single verses will be represented as ranges of length 1, ensuring all returned objects have the same schema.
Splits an array of ranges to form an array of individual verses
Converts a BibleVerse to a "Verse Index" which would be the 0-based index of the verse in an array contain all verse of the bible
Validates a BibleRef, returning an array of errors, or empty array if no issues Note that the .ref field of each error produced will be a reference to the BibleRef passed in rather than a copy
if true then warning messages will be included
Given a (potentially non-continous) set of BibleRef's, finds the BibleVerse at the specified index. This is the inverse of indexOf
The set of BibleRef instances (or singular instance) to extract a verse from
The zero based index of the verse you wish to extract from the input set
BibleVerse instance, or undefined if index
is out of bounds
Generated using TypeDoc
Union type that represents any continous section of bible, including a single verse, to a span of text over multiple chapters/books