Skip to content

@gracious.tech/fetch-client / collection / BibleCollection

Class: BibleCollection

collection.BibleCollection

Access to a collection’s meta data, including languages and translations available

Methods

has_language

has_language(language): boolean

Check if a language exists (must be 3 character id)

Parameters

NameType
languagestring

Returns

boolean

Defined in

client/src/collection.ts:204


has_translation

has_translation(translation): boolean

Check if a translation exists

Parameters

NameType
translationstring

Returns

boolean

Defined in

client/src/collection.ts:209


has_book

has_book(translation, book): boolean

Check if a book exists within a translation

Parameters

NameType
translationstring
bookstring

Returns

boolean

Defined in

client/src/collection.ts:214


get_languages

get_languages(options): Record<string, GetLanguagesItem>

Get available languages as either a list or an object

Parameters

NameType
optionsObjT<GetLanguagesOptions>

Returns

Record<string, GetLanguagesItem>

Defined in

client/src/collection.ts:219

get_languages(options?): GetLanguagesItem[]

Parameters

NameType
options?ObjF<GetLanguagesOptions>

Returns

GetLanguagesItem[]

Defined in

client/src/collection.ts:220


get_preferred_language

get_preferred_language(preferences?): string

Get the user’s preferred available language (no arg required when used in browser)

Parameters

NameTypeDefault value
preferencesstring[][]

Returns

string

Defined in

client/src/collection.ts:259


get_translations

get_translations(options): Record<string, GetTranslationsItem>

Get available translations as either a list or an object

Parameters

NameType
optionsObjT<GetTranslationsOptions>

Returns

Record<string, GetTranslationsItem>

Defined in

client/src/collection.ts:288

get_translations(options?): GetTranslationsItem[]

Parameters

NameType
options?ObjF<GetTranslationsOptions>

Returns

GetTranslationsItem[]

Defined in

client/src/collection.ts:289


get_preferred_translation

get_preferred_translation(languages?): string

Get user’s preferred available translation (provide language preferences if not in browser)

Parameters

NameTypeDefault value
languagesstring[][]

Returns

string

Defined in

client/src/collection.ts:349


get_books

get_books(translation, options): Record<string, GetBooksItem>

Get which books are available for a translation If no translation is given, all books will be listed but marked as unavailable

Parameters

NameType
translationundefined | string
optionsObjT<GetBooksOptions>

Returns

Record<string, GetBooksItem>

Defined in

client/src/collection.ts:389

get_books(translation?, options?): GetBooksItem[]

Parameters

NameType
translation?string
options?ObjF<GetBooksOptions>

Returns

GetBooksItem[]

Defined in

client/src/collection.ts:391


get_book_url

get_book_url(translation, book, format?): string

Get the URL for a book’s content (useful for caching and manual retrieval)

Parameters

NameTypeDefault value
translationstringundefined
bookstringundefined
format"html" | "usx" | "usfm" | "txt"'html'

Returns

string

Defined in

client/src/collection.ts:430


get_completion

get_completion(translation): GetCompletionReturn

Get book ids that are available/missing for a translation for each testament

Parameters

NameType
translationstring

Returns

GetCompletionReturn

Defined in

client/src/collection.ts:436


fetch_book

fetch_book(translation, book, format?): Promise<BibleBookHtml>

Make request for the text for a book of a translation (returns object for accessing it)

Parameters

NameType
translationstring
bookstring
format?"html"

Returns

Promise<BibleBookHtml>

Defined in

client/src/collection.ts:461

fetch_book(translation, book, format): Promise<BibleBookUsx>

Parameters

NameType
translationstring
bookstring
format"usx"

Returns

Promise<BibleBookUsx>

Defined in

client/src/collection.ts:462

fetch_book(translation, book, format): Promise<BibleBookUsfm>

Parameters

NameType
translationstring
bookstring
format"usfm"

Returns

Promise<BibleBookUsfm>

Defined in

client/src/collection.ts:463

fetch_book(translation, book, format): Promise<BibleBookTxt>

Parameters

NameType
translationstring
bookstring
format"txt"

Returns

Promise<BibleBookTxt>

Defined in

client/src/collection.ts:464


detect_references

detect_references(text, translation?, always_detect_english?): Generator<PassageReferenceMatch, null, undefined>

Detect bible references in a block of text using book names of given translation(s) A generator is returned and can be passed updated text each time it yields a result

Parameters

NameTypeDefault value
textstringundefined
translationstring | string[][]
always_detect_englishbooleantrue

Returns

Generator<PassageReferenceMatch, null, undefined>

Defined in

client/src/collection.ts:528


string_to_reference

string_to_reference(text, translation?, always_detect_english?): null | PassageReference

Parse a single bible reference string into a PassageReference object (validating it) Supports only single passages (for e.g. Matt 10:6,8 use detect_references)

Parameters

NameTypeDefault value
textstringundefined
translationstring | string[][]
always_detect_englishbooleantrue

Returns

null | PassageReference

Defined in

client/src/collection.ts:534


reference_to_string

reference_to_string(reference, translation?): string

Render a PassageReference object as a string using the given translation’s book names

Parameters

NameType
referencePassageReference
translation?string

Returns

string

Defined in

client/src/collection.ts:541