Skip to content

Commit

Permalink
Fix TS export
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Best-Codes committed Sep 9, 2024
1 parent 1f0fafe commit 57efd00
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 86 deletions.
10 changes: 5 additions & 5 deletions dist/browser/best-bible.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/browser/best-bible.min.js.map

Large diffs are not rendered by default.

70 changes: 51 additions & 19 deletions dist/cjs/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseVerse = parseVerse;
exports.getVerse = getVerse;
exports.getChapter = getChapter;
exports.getBook = getBook;
exports.getChapterCount = getChapterCount;
exports.getVerseCount = getVerseCount;
exports.getBibleBooks = getBibleBooks;
exports.getRange = getRange;
exports.searchVerse = searchVerse;
exports.resolveAbbreviation = resolveAbbreviation;
exports.bibleStats = bibleStats;
exports.bibleValidation = bibleValidation;
// @ts-ignore
const bibleData = require(`./data/bible.json`);
// @ts-ignore
Expand All @@ -16,6 +29,7 @@ isValidVerse, } = require(`./utils/validation`);
* @param {string} verse - The verse string to parse.
* @param {string} [outputType="default"] - The type of output. Can be "default", "string", or "indexed".
* @return {Array|String} The parsed verse based on the output type.
* @deprecated The bible.json file no longer has translation markers, so this function is not needed.
*/
function parseVerse(verse, outputType = "default") {
/* @deprecated: The bible.json file will resolve these errors itself. */
Expand Down Expand Up @@ -55,7 +69,11 @@ function parseVerse(verse, outputType = "default") {
* @param {boolean} [cleanVerse=true] - Whether to clean the verse before returning it.
* @return {Array|string} The content of the requested verse based on the output type.
*/
function getVerse(bookName, chapterNumber, verseNumber, outputType = "default", cleanVerse = true) {
function getVerse(bookName, chapterNumber, verseNumber, outputType = "default",
/**
* @deprecated Use of `cleanVerse` will be removed in a future version. Verses are now always cleaned by default.
*/
cleanVerse = true) {
if (!isValidVerse(bookName, chapterNumber, verseNumber)) {
throw new Error("Invalid verse reference");
}
Expand Down Expand Up @@ -90,7 +108,11 @@ function getVerse(bookName, chapterNumber, verseNumber, outputType = "default",
* @param {boolean} [cleanVerse=true] - Whether to clean the verse before returning it.
* @return {Array|String} The information about the chapter based on the output type.
*/
function getChapter(bookName, chapterNumber, outputType = "default", cleanVerse = true) {
function getChapter(bookName, chapterNumber, outputType = "default",
/**
* @deprecated Use of `cleanVerse` will be removed in a future version. Verses are now always cleaned by default.
*/
cleanVerse = true) {
if (!isValidChapter(bookName, chapterNumber)) {
throw new Error("Invalid chapter reference");
}
Expand Down Expand Up @@ -121,7 +143,11 @@ function getChapter(bookName, chapterNumber, outputType = "default", cleanVerse
* @param {boolean} [cleanVerse=true] - Whether to clean the verse before returning it.
* @return {Array|String|Object} The information about the book based on the output type.
*/
function getBook(bookName, outputType = "default", cleanVerse = true) {
function getBook(bookName, outputType = "default",
/**
* @deprecated Use of `cleanVerse` will be removed in a future version. Verses are now always cleaned by default.
*/
cleanVerse = true) {
if (!isValidBook(bookName)) {
throw new Error("Invalid book name");
}
Expand Down Expand Up @@ -195,7 +221,11 @@ function getBibleBooks() {
* @throws {Error} Throws an error if the verse reference is invalid.
* @return {Array|string} Returns an array of verses or a string of verses depending on the outputType.
*/
function getRange(startBookName, startChapterNumber, startVerseNumber, endBookName, endChapterNumber, endVerseNumber, outputType = "default", cleanVerse = true) {
function getRange(startBookName, startChapterNumber, startVerseNumber, endBookName, endChapterNumber, endVerseNumber, outputType = "default",
/**
* @deprecated Use of `cleanVerse` will be removed in a future version. Verses are now always cleaned by default.
*/
cleanVerse = true) {
if (!isValidVerse(startBookName, startChapterNumber, startVerseNumber) ||
!isValidVerse(endBookName, endChapterNumber, endVerseNumber)) {
throw new Error("Invalid verse reference");
Expand Down Expand Up @@ -325,24 +355,26 @@ function bibleStats() {
*
* @return {Object} An object with the validation functions as properties.
*/
function validators() {
function bibleValidation() {
return {
isValidBook,
isValidChapter,
isValidVerse,
};
}
module.exports = {
getVerse,
getChapter,
getBook,
getRange,
getChapterCount,
getVerseCount,
getBibleBooks,
searchVerse,
parseVerse,
resolveAbbreviation,
bibleStats,
bibleValidation: Object.assign({}, validators()),
};
/* module.exports = {
getVerse,
getChapter,
getBook,
getRange,
getChapterCount,
getVerseCount,
getBibleBooks,
searchVerse,
parseVerse,
resolveAbbreviation,
bibleStats,
bibleValidation: {
...validators(),
},
}; */
74 changes: 45 additions & 29 deletions dist/esm/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"use strict";
// @ts-ignore
const bibleData = require(`./data/bible.json`);
// @ts-ignore
Expand All @@ -16,8 +15,9 @@ isValidVerse, } = require(`./utils/validation`);
* @param {string} verse - The verse string to parse.
* @param {string} [outputType="default"] - The type of output. Can be "default", "string", or "indexed".
* @return {Array|String} The parsed verse based on the output type.
* @deprecated The bible.json file no longer has translation markers, so this function is not needed.
*/
function parseVerse(verse, outputType = "default") {
export function parseVerse(verse, outputType = "default") {
/* @deprecated: The bible.json file will resolve these errors itself. */
// Remove translation identifiers (text within square brackets)
//let cleanedVerse = verse.replace(/\[(.*?)\]/g, "$1");
Expand Down Expand Up @@ -55,7 +55,11 @@ function parseVerse(verse, outputType = "default") {
* @param {boolean} [cleanVerse=true] - Whether to clean the verse before returning it.
* @return {Array|string} The content of the requested verse based on the output type.
*/
function getVerse(bookName, chapterNumber, verseNumber, outputType = "default", cleanVerse = true) {
export function getVerse(bookName, chapterNumber, verseNumber, outputType = "default",
/**
* @deprecated Use of `cleanVerse` will be removed in a future version. Verses are now always cleaned by default.
*/
cleanVerse = true) {
if (!isValidVerse(bookName, chapterNumber, verseNumber)) {
throw new Error("Invalid verse reference");
}
Expand Down Expand Up @@ -90,7 +94,11 @@ function getVerse(bookName, chapterNumber, verseNumber, outputType = "default",
* @param {boolean} [cleanVerse=true] - Whether to clean the verse before returning it.
* @return {Array|String} The information about the chapter based on the output type.
*/
function getChapter(bookName, chapterNumber, outputType = "default", cleanVerse = true) {
export function getChapter(bookName, chapterNumber, outputType = "default",
/**
* @deprecated Use of `cleanVerse` will be removed in a future version. Verses are now always cleaned by default.
*/
cleanVerse = true) {
if (!isValidChapter(bookName, chapterNumber)) {
throw new Error("Invalid chapter reference");
}
Expand Down Expand Up @@ -121,7 +129,11 @@ function getChapter(bookName, chapterNumber, outputType = "default", cleanVerse
* @param {boolean} [cleanVerse=true] - Whether to clean the verse before returning it.
* @return {Array|String|Object} The information about the book based on the output type.
*/
function getBook(bookName, outputType = "default", cleanVerse = true) {
export function getBook(bookName, outputType = "default",
/**
* @deprecated Use of `cleanVerse` will be removed in a future version. Verses are now always cleaned by default.
*/
cleanVerse = true) {
if (!isValidBook(bookName)) {
throw new Error("Invalid book name");
}
Expand Down Expand Up @@ -153,7 +165,7 @@ function getBook(bookName, outputType = "default", cleanVerse = true) {
* @throws {Error} Throws an error if the book name is invalid.
* @return {number} The number of chapters in the specified book.
*/
function getChapterCount(bookName) {
export function getChapterCount(bookName) {
if (!isValidBook(bookName)) {
throw new Error("Invalid book name");
}
Expand All @@ -167,7 +179,7 @@ function getChapterCount(bookName) {
* @throws {Error} Throws an error if the chapter reference is invalid.
* @return {number} The number of verses in the specified chapter.
*/
function getVerseCount(bookName, chapterNumber) {
export function getVerseCount(bookName, chapterNumber) {
if (!isValidChapter(bookName, chapterNumber)) {
throw new Error("Invalid chapter reference");
}
Expand All @@ -178,7 +190,7 @@ function getVerseCount(bookName, chapterNumber) {
*
* @return {Array} An array containing the names of all the Bible books.
*/
function getBibleBooks() {
export function getBibleBooks() {
return Object.keys(bibleData);
}
/**
Expand All @@ -195,7 +207,11 @@ function getBibleBooks() {
* @throws {Error} Throws an error if the verse reference is invalid.
* @return {Array|string} Returns an array of verses or a string of verses depending on the outputType.
*/
function getRange(startBookName, startChapterNumber, startVerseNumber, endBookName, endChapterNumber, endVerseNumber, outputType = "default", cleanVerse = true) {
export function getRange(startBookName, startChapterNumber, startVerseNumber, endBookName, endChapterNumber, endVerseNumber, outputType = "default",
/**
* @deprecated Use of `cleanVerse` will be removed in a future version. Verses are now always cleaned by default.
*/
cleanVerse = true) {
if (!isValidVerse(startBookName, startChapterNumber, startVerseNumber) ||
!isValidVerse(endBookName, endChapterNumber, endVerseNumber)) {
throw new Error("Invalid verse reference");
Expand Down Expand Up @@ -257,7 +273,7 @@ function getRange(startBookName, startChapterNumber, startVerseNumber, endBookNa
* @param {string} [outputType="indexed"] - The type of output format desired (indexed or string).
* @return {Array|string} The matching verses based on the output type.
*/
function searchVerse(query, caseSensitive = false, exactMatch = false, outputType = "indexed") {
export function searchVerse(query, caseSensitive = false, exactMatch = false, outputType = "indexed") {
let searchResults = [];
// Normalize query based on case sensitivity
const normalizedQuery = caseSensitive ? query : query.toLowerCase();
Expand Down Expand Up @@ -304,15 +320,15 @@ function searchVerse(query, caseSensitive = false, exactMatch = false, outputTyp
* @param {string} abbreviation - The abbreviation to resolve.
* @return {string} The full name corresponding to the abbreviation.
*/
function resolveAbbreviation(abbreviation) {
export function resolveAbbreviation(abbreviation) {
return abbreviations[abbreviation] || abbreviation;
}
/**
* Returns an object containing the number of books, chapters, and verses in the Bible.
*
* @return {Object} An object with the number of books, chapters, and verses in the Bible.
*/
function bibleStats() {
export function bibleStats() {
return {
books: Object.keys(bibleData).length,
chapters: Object.values(bibleData).reduce((sum, book) => sum + Object.keys(book).length, 0),
Expand All @@ -325,26 +341,26 @@ function bibleStats() {
*
* @return {Object} An object with the validation functions as properties.
*/
function validators() {
export function bibleValidation() {
return {
isValidBook,
isValidChapter,
isValidVerse,
};
}
module.exports = {
getVerse,
getChapter,
getBook,
getRange,
getChapterCount,
getVerseCount,
getBibleBooks,
searchVerse,
parseVerse,
resolveAbbreviation,
bibleStats,
bibleValidation: {
...validators(),
},
};
/* module.exports = {
getVerse,
getChapter,
getBook,
getRange,
getChapterCount,
getVerseCount,
getBibleBooks,
searchVerse,
parseVerse,
resolveAbbreviation,
bibleStats,
bibleValidation: {
...validators(),
},
}; */
Loading

0 comments on commit 57efd00

Please sign in to comment.