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:256


has_translation

has_translation(translation): boolean

Check if a translation exists

Parameters

NameType
translationstring

Returns

boolean

Defined in

client/src/collection.ts:261


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:266


get_language

get_language(code): undefined | GetLanguagesItem

Get a language’s metadata

Parameters

NameType
codestring

Returns

undefined | GetLanguagesItem

Defined in

client/src/collection.ts:273


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:289

get_languages(options?): GetLanguagesItem[]

Parameters

NameType
options?ObjF<GetLanguagesOptions>

Returns

GetLanguagesItem[]

Defined in

client/src/collection.ts:290


get_preferred_language

get_preferred_language(preferences?): GetLanguagesItem

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

Parameters

NameTypeDefault value
preferencesstring[][]

Returns

GetLanguagesItem

Defined in

client/src/collection.ts:345


get_translation

get_translation(id): undefined | GetTranslationsItem

Get a translation’s metadata

Parameters

NameType
idstring

Returns

undefined | GetTranslationsItem

Defined in

client/src/collection.ts:379


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:427

get_translations(options?): GetTranslationsItem[]

Parameters

NameType
options?ObjF<GetTranslationsOptions>

Returns

GetTranslationsItem[]

Defined in

client/src/collection.ts:428


get_preferred_translation

get_preferred_translation(languages?): GetTranslationsItem

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

Parameters

NameTypeDefault value
languagesstring[][]

Returns

GetTranslationsItem

Defined in

client/src/collection.ts:484


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. If fetch_translation_extras() has already been called for the translation then local name data will also be available (otherwise only English book names will be available).

Parameters

NameType
translationundefined | string
optionsObjT<GetBooksOptions>

Returns

Record<string, GetBooksItem>

Defined in

client/src/collection.ts:532

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

Parameters

NameType
translation?string
options?ObjF<GetBooksOptions>

Returns

GetBooksItem[]

Defined in

client/src/collection.ts:534


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:602


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:608


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:634

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

Parameters

NameType
translationstring
bookstring
format"usx"

Returns

Promise<BibleBookUsx>

Defined in

client/src/collection.ts:635

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

Parameters

NameType
translationstring
bookstring
format"usfm"

Returns

Promise<BibleBookUsfm>

Defined in

client/src/collection.ts:636

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

Parameters

NameType
translationstring
bookstring
format"txt"

Returns

Promise<BibleBookTxt>

Defined in

client/src/collection.ts:637


fetch_translation_extras

fetch_translation_extras(translation): Promise<TranslationExtra>

Make request for extra metadata for a translation (such as book names and section headings). This will also auto-provide local book names for future calls of get_books().

Parameters

NameType
translationstring

Returns

Promise<TranslationExtra>

Defined in

client/src/collection.ts:674


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. You must have first awaited a call to fetch_translation_extras() to be able to parse non-English references.

Parameters

NameTypeDefault value
textstringundefined
translationstring | string[][]
always_detect_englishbooleantrue

Returns

Generator<PassageReferenceMatch, null, undefined>

Defined in

client/src/collection.ts:758


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). You must have first awaited a call to fetch_translation_extras() to be able to parse non-English references.

Parameters

NameTypeDefault value
textstringundefined
translationstring | string[][]
always_detect_englishbooleantrue

Returns

null | PassageReference

Defined in

client/src/collection.ts:767


reference_to_string

reference_to_string(reference, translation?, abbreviate?): string

Render a PassageReference object as a string using the given translation’s book names. You must have first awaited a call to fetch_translation_extras() for the translation, or English will be used by default.

Parameters

NameType
referencePassageReference
translation?string
abbreviate?boolean

Returns

string

Defined in

client/src/collection.ts:775