Appearance
@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
| Name | Type |
|---|---|
language | string |
Returns
boolean
Defined in
has_translation
▸ has_translation(translation): boolean
Check if a translation exists
Parameters
| Name | Type |
|---|---|
translation | string |
Returns
boolean
Defined in
has_book
▸ has_book(translation, book): boolean
Check if a book exists within a translation
Parameters
| Name | Type |
|---|---|
translation | string |
book | string |
Returns
boolean
Defined in
get_language
▸ get_language(code): undefined | GetLanguagesItem
Get a language’s metadata
Parameters
| Name | Type |
|---|---|
code | string |
Returns
undefined | GetLanguagesItem
Defined in
get_languages
▸ get_languages(options): Record<string, GetLanguagesItem>
Get available languages as either a list or an object
Parameters
| Name | Type |
|---|---|
options | ObjT<GetLanguagesOptions> |
Returns
Record<string, GetLanguagesItem>
Defined in
▸ get_languages(options?): GetLanguagesItem[]
Parameters
| Name | Type |
|---|---|
options? | ObjF<GetLanguagesOptions> |
Returns
Defined in
get_preferred_language
▸ get_preferred_language(preferences?): GetLanguagesItem
Get the user’s preferred available language (no arg required when used in browser)
Parameters
| Name | Type | Default value |
|---|---|---|
preferences | string[] | [] |
Returns
Defined in
get_translation
▸ get_translation(id): undefined | GetTranslationsItem
Get a translation’s metadata
Parameters
| Name | Type |
|---|---|
id | string |
Returns
undefined | GetTranslationsItem
Defined in
get_translations
▸ get_translations(options): Record<string, GetTranslationsItem>
Get available translations as either a list or an object
Parameters
| Name | Type |
|---|---|
options | ObjT<GetTranslationsOptions> |
Returns
Record<string, GetTranslationsItem>
Defined in
▸ get_translations(options?): GetTranslationsItem[]
Parameters
| Name | Type |
|---|---|
options? | ObjF<GetTranslationsOptions> |
Returns
Defined in
get_preferred_translation
▸ get_preferred_translation(languages?): GetTranslationsItem
Get user’s preferred available translation (provide language preferences if not in browser)
Parameters
| Name | Type | Default value |
|---|---|---|
languages | string[] | [] |
Returns
Defined in
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
| Name | Type |
|---|---|
translation | undefined | string |
options | ObjT<GetBooksOptions> |
Returns
Record<string, GetBooksItem>
Defined in
▸ get_books(translation?, options?): GetBooksItem[]
Parameters
| Name | Type |
|---|---|
translation? | string |
options? | ObjF<GetBooksOptions> |
Returns
Defined in
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
| Name | Type | Default value |
|---|---|---|
translation | string | undefined |
book | string | undefined |
format | "html" | "usx" | "usfm" | "txt" | 'html' |
Returns
string
Defined in
get_completion
▸ get_completion(translation): GetCompletionReturn
Get book ids that are available/missing for a translation for each testament
Parameters
| Name | Type |
|---|---|
translation | string |
Returns
Defined in
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
| Name | Type |
|---|---|
translation | string |
book | string |
format? | "html" |
Returns
Promise<BibleBookHtml>
Defined in
▸ fetch_book(translation, book, format): Promise<BibleBookUsx>
Parameters
| Name | Type |
|---|---|
translation | string |
book | string |
format | "usx" |
Returns
Promise<BibleBookUsx>
Defined in
▸ fetch_book(translation, book, format): Promise<BibleBookUsfm>
Parameters
| Name | Type |
|---|---|
translation | string |
book | string |
format | "usfm" |
Returns
Promise<BibleBookUsfm>
Defined in
▸ fetch_book(translation, book, format): Promise<BibleBookTxt>
Parameters
| Name | Type |
|---|---|
translation | string |
book | string |
format | "txt" |
Returns
Promise<BibleBookTxt>
Defined in
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
| Name | Type |
|---|---|
translation | string |
Returns
Promise<TranslationExtra>
Defined in
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
| Name | Type | Default value |
|---|---|---|
text | string | undefined |
translation | string | string[] | [] |
always_detect_english | boolean | true |
Returns
Generator<PassageReferenceMatch, null, undefined>
Defined in
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
| Name | Type | Default value |
|---|---|---|
text | string | undefined |
translation | string | string[] | [] |
always_detect_english | boolean | true |
Returns
null | PassageReference
Defined in
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
| Name | Type |
|---|---|
reference | PassageReference |
translation? | string |
abbreviate? | boolean |
Returns
string