Skip to content

Commit

Permalink
better typing, esmodules in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Best-Codes committed Jan 2, 2025
1 parent 6303187 commit ba898f8
Show file tree
Hide file tree
Showing 12 changed files with 351 additions and 258 deletions.
10 changes: 5 additions & 5 deletions dist/browser/best-bible.min.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/cjs/index.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/esm/index.js

Large diffs are not rendered by default.

177 changes: 107 additions & 70 deletions dist/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,127 +1,164 @@
declare module "utils/abbreviations" {
const abbreviations: {
[key: string]: string;
};
export default abbreviations;
}
declare module "utils/validation" {
/**
* Checks if the provided book name is a valid entry in the bibleData.
*
* @param bookName - The name of the book to check.
* @return Indicates whether the book name is valid.
*/
function isValidBook(bookName: string): boolean;
/**
* Checks if the given chapter number is valid for the specified book.
*
* @param bookName - The name of the book.
* @param chapterNumber - The number of the chapter.
* @return Returns true if the chapter number is valid, false otherwise.
*/
function isValidChapter(bookName: string, chapterNumber: number): boolean;
/**
* Checks if the given verse number is valid for the specified book and chapter.
*
* @param bookName - The name of the book.
* @param chapterNumber - The number of the chapter.
* @param verseNumber - The number of the verse.
* @return Returns true if the verse number is valid, false otherwise.
*/
function isValidVerse(bookName: string, chapterNumber: number, verseNumber: number): boolean;
export { isValidBook, isValidChapter, isValidVerse };
}
declare module "index" {
interface Word {
word: string;
index: number;
}
interface VerseResult {
key: string;
book: string;
chapter: string;
verse: string;
content: string;
}
/**
* Parses a verse string and returns either an array of word objects or a cleaned string.
*
* @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.
* @param verse - The verse string to parse.
* @param outputType - The type of output. Can be "default", "string", or "indexed".
* @return The parsed verse based on the output type.
* @deprecated The bible.json file no longer has translation markers, so this function is not needed.
*/
export function parseVerse(verse: string, outputType?: string): string | {
word: string;
index: number;
}[];
export function parseVerse(verse: string, outputType?: "default" | "string" | "indexed"): Array<Word> | string;
/**
* Retrieves a specific verse from the Bible data based on the provided book name, chapter number, and verse number.
*
* @param {string} bookName - The name of the book containing the verse.
* @param {number} chapterNumber - The number of the chapter containing the verse.
* @param {number} verseNumber - The number of the verse to retrieve.
* @param {string} [outputType="default"] - The type of output format desired (indexed or string).
* @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.
* @param bookName - The name of the book containing the verse.
* @param chapterNumber - The number of the chapter containing the verse.
* @param verseNumber - The number of the verse to retrieve.
* @param outputType - The type of output format desired (indexed or string).
* @param cleanVerse - Whether to clean the verse before returning it.
* @return The content of the requested verse based on the output type.
*/
export function getVerse(bookName: string, chapterNumber: number, verseNumber: number, outputType?: string,
export function getVerse(bookName: string, chapterNumber: number, verseNumber: number, outputType?: "default" | "indexed" | "string",
/**
* @deprecated Use of `cleanVerse` will be removed in a future version. Verses are now always cleaned by default.
*/
cleanVerse?: boolean): string | any[];
cleanVerse?: boolean): Array<VerseResult> | string | string[];
/**
* Retrieves information about a chapter from the Bible data.
*
* @param {string} bookName - The name of the book containing the chapter.
* @param {number} chapterNumber - The number of the chapter to retrieve.
* @param {string} [outputType="default"] - The type of output format desired (indexed or string).
* @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.
* @param bookName - The name of the book containing the chapter.
* @param chapterNumber - The number of the chapter to retrieve.
* @param outputType - The type of output format desired (indexed or string).
* @param cleanVerse - Whether to clean the verse before returning it.
* @return The information about the chapter based on the output type.
*/
export function getChapter(bookName: string, chapterNumber: number, outputType?: string,
export function getChapter(bookName: string, chapterNumber: number, outputType?: "default" | "indexed" | "string",
/**
* @deprecated Use of `cleanVerse` will be removed in a future version. Verses are now always cleaned by default.
*/
cleanVerse?: boolean): any;
cleanVerse?: boolean): Array<VerseResult> | string | string[];
/**
* Retrieves information about a book from the Bible data.
*
* @param {string} bookName - The name of the book to retrieve.
* @param {string} [outputType="default"] - The type of output format desired (indexed or string).
* @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.
* @param bookName - The name of the book to retrieve.
* @param outputType - The type of output format desired (indexed or string).
* @param cleanVerse - Whether to clean the verse before returning it.
* @return The information about the book based on the output type.
*/
export function getBook(bookName: string, outputType?: string,
export function getBook(bookName: string, outputType?: "default" | "indexed" | "string",
/**
* @deprecated Use of `cleanVerse` will be removed in a future version. Verses are now always cleaned by default.
*/
cleanVerse?: boolean): any;
cleanVerse?: boolean): Array<VerseResult> | string | {
[key: string]: string[];
};
/**
* Retrieves the number of chapters in a specific book of the Bible.
*
* @param {string} bookName - The name of the book.
* @throws {Error} Throws an error if the book name is invalid.
* @return {number} The number of chapters in the specified book.
* @param bookName - The name of the book.
* @throws Throws an error if the book name is invalid.
* @return The number of chapters in the specified book.
*/
export function getChapterCount(bookName: string): number;
/**
* Retrieves the number of verses in a specific chapter of a book in the Bible.
*
* @param {string} bookName - The name of the book.
* @param {number} chapterNumber - The number of the chapter.
* @throws {Error} Throws an error if the chapter reference is invalid.
* @return {number} The number of verses in the specified chapter.
* @param bookName - The name of the book.
* @param chapterNumber - The number of the chapter.
* @throws Throws an error if the chapter reference is invalid.
* @return The number of verses in the specified chapter.
*/
export function getVerseCount(bookName: string, chapterNumber: number): any;
export function getVerseCount(bookName: string, chapterNumber: number): number;
/**
* Retrieves the list of Bible books.
*
* @return {Array} An array containing the names of all the Bible books.
* @return An array containing the names of all the Bible books.
*/
export function getBibleBooks(): string[];
/**
* Retrieves a range of verses from the Bible based on the provided start and end references.
*
* @param {string} startBookName - The name of the starting book.
* @param {number} startChapterNumber - The number of the starting chapter.
* @param {number} startVerseNumber - The number of the starting verse.
* @param {string} endBookName - The name of the ending book.
* @param {number} endChapterNumber - The number of the ending chapter.
* @param {number} endVerseNumber - The number of the ending verse.
* @param {string} [outputType="default"] - The type of output. Can be "indexed", "string", or "default".
* @param {boolean} [cleanVerse=true] - Whether to clean the verse before returning it.
* @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.
*/
export function getRange(startBookName: string, startChapterNumber: number, startVerseNumber: number, endBookName: string, endChapterNumber: number, endVerseNumber: number, outputType?: string,
* @param startBookName - The name of the starting book.
* @param startChapterNumber - The number of the starting chapter.
* @param startVerseNumber - The number of the starting verse.
* @param endBookName - The name of the ending book.
* @param endChapterNumber - The number of the ending chapter.
* @param endVerseNumber - The number of the ending verse.
* @param outputType - The type of output. Can be "indexed", "string", or "default".
* @param cleanVerse - Whether to clean the verse before returning it.
* @throws Throws an error if the verse reference is invalid.
* @return Returns an array of verses or a string of verses depending on the outputType.
*/
export function getRange(startBookName: string, startChapterNumber: number, startVerseNumber: number, endBookName: string, endChapterNumber: number, endVerseNumber: number, outputType?: "default" | "indexed" | "string",
/**
* @deprecated Use of `cleanVerse` will be removed in a future version. Verses are now always cleaned by default.
*/
cleanVerse?: boolean): string | any[];
cleanVerse?: boolean): Array<VerseResult> | string | string[];
/**
* Searches for a query string in each verse of the Bible and returns the matching verses.
*
* @param {string} query - The query string to search for.
* @param {boolean} [caseSensitive=false] - Whether the search should be case sensitive.
* @param {boolean} [exactMatch=false] - Whether the search should match the exact phrase.
* @param {string} [outputType="indexed"] - The type of output format desired (indexed or string).
* @return {Array|string} The matching verses based on the output type.
* @param query - The query string to search for.
* @param caseSensitive - Whether the search should be case sensitive.
* @param exactMatch - Whether the search should match the exact phrase.
* @param outputType - The type of output format desired (indexed or string).
* @return The matching verses based on the output type.
*/
export function searchVerse(query: string, caseSensitive?: boolean, exactMatch?: boolean, outputType?: string): string | {
key: string;
book: string;
chapter: string;
verse: string;
content: any;
}[] | undefined;
export function searchVerse(query: string, caseSensitive?: boolean, exactMatch?: boolean, outputType?: "indexed" | "string"): Array<VerseResult> | string;
/**
* Resolves an abbreviation to its full name.
*
* @param {string} abbreviation - The abbreviation to resolve.
* @return {string} The full name corresponding to the abbreviation.
* @param abbreviation - The abbreviation to resolve.
* @return The full name corresponding to the abbreviation.
*/
export function resolveAbbreviation(abbreviation: string): any;
export function resolveAbbreviation(abbreviation: string): string;
/**
* 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.
* @return An object with the number of books, chapters, and verses in the Bible.
*/
export function bibleStats(): {
books: number;
Expand All @@ -131,11 +168,11 @@ declare module "index" {
/**
* Returns an object containing the three validation functions: `isValidBook`, `isValidChapter`, and `isValidVerse`.
*
* @return {Object} An object with the validation functions as properties.
* @return An object with the validation functions as properties.
*/
export function bibleValidation(): {
isValidBook: any;
isValidChapter: any;
isValidVerse: any;
isValidBook: (bookName: string) => boolean;
isValidChapter: (bookName: string, chapterNumber: number) => boolean;
isValidVerse: (bookName: string, chapterNumber: number, verseNumber: number) => boolean;
};
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "best-bible",
"version": "1.7.1",
"version": "1.7.2",
"description": "Fetch, parse, and analyze the Bible easily with JavaScript",
"scripts": {
"prebuild": "rm -rf dist",
Expand All @@ -12,7 +12,7 @@
"prepublishOnly": "bun run build",
"test": "bun test"
},
"packageManager": "[email protected].38",
"packageManager": "[email protected].42",
"files": [
"dist",
"README.md",
Expand Down
Loading

0 comments on commit ba898f8

Please sign in to comment.