diff --git a/dist/cjs/index.js b/dist/cjs/index.js index 94b8fbf..8fe86e1 100644 --- a/dist/cjs/index.js +++ b/dist/cjs/index.js @@ -1,380 +1 @@ -"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 -const abbreviations = require(`./utils/abbreviations`); -const { -// @ts-ignore -isValidBook, -// @ts-ignore -isValidChapter, -// @ts-ignore -isValidVerse, } = require(`./utils/validation`); -/** - * 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. - * @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. */ - // Remove translation identifiers (text within square brackets) - //let cleanedVerse = verse.replace(/\[(.*?)\]/g, "$1"); - // Remove any '#' at the start of the verse - //cleanedVerse = cleanedVerse.replace(/^#\s*/, ""); - // Trim any extra whitespace - //cleanedVerse = cleanedVerse.trim(); - // Remove multiple spaces - //cleanedVerse = cleanedVerse.replace(/\s+/g, " "); - /* @end-deprecated */ - let cleanedVerse = verse; - if (outputType === "default" || outputType === "string") { - return cleanedVerse; - } - else if (outputType === "indexed") { - // Split the cleaned verse into words - const words = cleanedVerse.split(" "); - // Create an array of word objects - return words.map((word, index) => ({ - word: word, - index: index, - })); - } - else { - throw new Error("Invalid outputType. Use 'default' or 'indexed'."); - } -} -/** - * 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. - */ -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"); - } - let content = bibleData[bookName][chapterNumber][verseNumber - 1]; - if (cleanVerse) { - content = parseVerse(content, "string"); - } - if (outputType === "indexed") { - return [ - { - key: `${bookName} ${chapterNumber}:${verseNumber}`, - book: bookName, - chapter: chapterNumber.toString(), - verse: verseNumber.toString(), - content: content, - }, - ]; - } - else if (outputType === "string") { - return `${bookName} ${chapterNumber}:${verseNumber} - ${content}`; - } - else { - return [content]; - } -} -/** - * 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. - */ -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"); - } - const verses = bibleData[bookName][chapterNumber]; - if (outputType === "indexed") { - return verses.map((content, index) => ({ - key: `${bookName} ${chapterNumber}:${index + 1}`, - book: bookName, - chapter: chapterNumber.toString(), - verse: (index + 1).toString(), - content: cleanVerse ? parseVerse(content, "string") : content, - })); - } - else if (outputType === "string") { - return verses - .map((content, index) => `${bookName} ${chapterNumber}:${index + 1} - ${cleanVerse ? parseVerse(content, "string") : content}`) - .join("\n"); - } - else { - return verses; - } -} -/** - * 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. - */ -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"); - } - const chapters = bibleData[bookName]; - if (outputType === "indexed") { - return Object.entries(chapters).flatMap(([chapterNumber, verses]) => verses.map((content, index) => ({ - key: `${bookName} ${chapterNumber}:${index + 1}`, - book: bookName, - chapter: chapterNumber, - verse: (index + 1).toString(), - content: cleanVerse ? parseVerse(content, "string") : content, - }))); - } - else if (outputType === "string") { - return Object.entries(chapters) - .map(([chapterNumber, verses]) => verses - .map((content, index) => `${bookName} ${chapterNumber}:${index + 1} - ${cleanVerse ? parseVerse(content, "string") : content}`) - .join("\n")) - .join("\n\n"); - } - else { - return chapters; - } -} -/** - * 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. - */ -function getChapterCount(bookName) { - if (!isValidBook(bookName)) { - throw new Error("Invalid book name"); - } - return Object.keys(bibleData[bookName]).length; -} -/** - * 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. - */ -function getVerseCount(bookName, chapterNumber) { - if (!isValidChapter(bookName, chapterNumber)) { - throw new Error("Invalid chapter reference"); - } - return bibleData[bookName][chapterNumber].length; -} -/** - * Retrieves the list of Bible books. - * - * @return {Array} An array containing the names of all the Bible books. - */ -function getBibleBooks() { - return Object.keys(bibleData); -} -/** - * 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. - */ -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"); - } - var verses = []; - // Get the index of the start and end books - var startBookIndex = getBibleBooks().indexOf(startBookName); - var endBookIndex = getBibleBooks().indexOf(endBookName); - // Iterate through the books - for (var bookIndex = startBookIndex; bookIndex <= endBookIndex; bookIndex++) { - var bookName = getBibleBooks()[bookIndex]; - var startChapter = bookIndex === startBookIndex ? startChapterNumber : 1; - var endChapter = bookIndex === endBookIndex ? endChapterNumber : getChapterCount(bookName); - // Iterate through the chapters - for (var chapterNumber = startChapter; chapterNumber <= endChapter; chapterNumber++) { - var startVerse = bookIndex === startBookIndex && chapterNumber === startChapterNumber - ? startVerseNumber - : 1; - var endVerse = bookIndex === endBookIndex && chapterNumber === endChapterNumber - ? endVerseNumber - : getVerseCount(bookName, chapterNumber); - // Iterate through the verses - for (var verseNumber = startVerse; verseNumber <= endVerse; verseNumber++) { - let content = getVerse(bookName, chapterNumber, verseNumber)[0]; - if (cleanVerse) { - content = parseVerse(content, "string"); - } - if (outputType === "indexed") { - verses.push({ - key: `${bookName} ${chapterNumber}:${verseNumber}`, - book: bookName, - chapter: chapterNumber.toString(), - verse: verseNumber.toString(), - content: content, - }); - } - else if (outputType === "string") { - verses.push(`${bookName} ${chapterNumber}:${verseNumber} - ${content}`); - } - else { - verses.push(content); - } - } - } - } - if (outputType === "string") { - return verses.join("\n"); - } - else { - return verses; - } -} -/** - * 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. - */ -function searchVerse(query, caseSensitive = false, exactMatch = false, outputType = "indexed") { - let searchResults = []; - // Normalize query based on case sensitivity - const normalizedQuery = caseSensitive ? query : query.toLowerCase(); - for (let book in bibleData) { - for (let chapter in bibleData[book]) { - for (let verse in bibleData[book][chapter]) { - const verseContent = bibleData[book][chapter][verse]; - const normalizedContent = caseSensitive - ? verseContent - : verseContent.toLowerCase(); - // Check for exact match or substring match - let matchCondition; - if (exactMatch) { - const regex = new RegExp(`\\b${normalizedQuery}\\b`, caseSensitive ? "" : "i"); - matchCondition = regex.test(normalizedContent); - } - else { - matchCondition = normalizedContent.indexOf(normalizedQuery) !== -1; - } - if (matchCondition) { - searchResults.push({ - key: `${book} ${chapter}:${verse}`, - book: book, - chapter: chapter, - verse: verse, - content: verseContent, - }); - } - } - } - } - if (outputType === "string") { - return searchResults - .map((result) => `${result.book} ${result.chapter}:${result.verse} - ${result.content}`) - .join("\n"); - } - else if (outputType === "indexed") { - return searchResults; - } -} -/** - * Resolves an abbreviation to its full name. - * - * @param {string} abbreviation - The abbreviation to resolve. - * @return {string} The full name corresponding to the abbreviation. - */ -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() { - return { - books: Object.keys(bibleData).length, - chapters: Object.values(bibleData).reduce((sum, book) => sum + Object.keys(book).length, 0), - verses: Object.values(bibleData).reduce((sum, book) => sum + - Object.values(book).reduce((sum, chapter) => sum + chapter.length, 0), 0), - }; -} -/** - * Returns an object containing the three validation functions: `isValidBook`, `isValidChapter`, and `isValidVerse`. - * - * @return {Object} An object with the validation functions as properties. - */ -function bibleValidation() { - return { - isValidBook, - isValidChapter, - isValidVerse, - }; -} -/* module.exports = { - getVerse, - getChapter, - getBook, - getRange, - getChapterCount, - getVerseCount, - getBibleBooks, - searchVerse, - parseVerse, - resolveAbbreviation, - bibleStats, - bibleValidation: { - ...validators(), - }, -}; */ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),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;const bibleData=require("./data/bible.json"),abbreviations=require("./utils/abbreviations"),{isValidBook:isValidBook,isValidChapter:isValidChapter,isValidVerse:isValidVerse}=require("./utils/validation");function parseVerse(e,t="default"){if("default"===t||"string"===t)return e;if("indexed"===t){return e.split(" ").map(((e,t)=>({word:e,index:t})))}throw new Error("Invalid outputType. Use 'default' or 'indexed'.")}function getVerse(e,t,r,i="default",n=!0){if(!isValidVerse(e,t,r))throw new Error("Invalid verse reference");let o=bibleData[e][t][r-1];return n&&(o=parseVerse(o,"string")),"indexed"===i?[{key:`${e} ${t}:${r}`,book:e,chapter:t.toString(),verse:r.toString(),content:o}]:"string"===i?`${e} ${t}:${r} - ${o}`:[o]}function getChapter(e,t,r="default",i=!0){if(!isValidChapter(e,t))throw new Error("Invalid chapter reference");const n=bibleData[e][t];return"indexed"===r?n.map(((r,n)=>({key:`${e} ${t}:${n+1}`,book:e,chapter:t.toString(),verse:(n+1).toString(),content:i?parseVerse(r,"string"):r}))):"string"===r?n.map(((r,n)=>`${e} ${t}:${n+1} - ${i?parseVerse(r,"string"):r}`)).join("\n"):n}function getBook(e,t="default",r=!0){if(!isValidBook(e))throw new Error("Invalid book name");const i=bibleData[e];return"indexed"===t?Object.entries(i).flatMap((([t,i])=>i.map(((i,n)=>({key:`${e} ${t}:${n+1}`,book:e,chapter:t,verse:(n+1).toString(),content:r?parseVerse(i,"string"):i}))))):"string"===t?Object.entries(i).map((([t,i])=>i.map(((i,n)=>`${e} ${t}:${n+1} - ${r?parseVerse(i,"string"):i}`)).join("\n"))).join("\n\n"):i}function getChapterCount(e){if(!isValidBook(e))throw new Error("Invalid book name");return Object.keys(bibleData[e]).length}function getVerseCount(e,t){if(!isValidChapter(e,t))throw new Error("Invalid chapter reference");return bibleData[e][t].length}function getBibleBooks(){return Object.keys(bibleData)}function getRange(e,t,r,i,n,o,s="default",a=!0){if(!isValidVerse(e,t,r)||!isValidVerse(i,n,o))throw new Error("Invalid verse reference");for(var l=[],b=getBibleBooks().indexOf(e),d=getBibleBooks().indexOf(i),p=b;p<=d;p++)for(var u=getBibleBooks()[p],g=p===b?t:1,c=p===d?n:getChapterCount(u),V=g;V<=c;V++)for(var f=p===b&&V===t?r:1,h=p===d&&V===n?o:getVerseCount(u,V),$=f;$<=h;$++){let e=getVerse(u,V,$)[0];a&&(e=parseVerse(e,"string")),"indexed"===s?l.push({key:`${u} ${V}:${$}`,book:u,chapter:V.toString(),verse:$.toString(),content:e}):"string"===s?l.push(`${u} ${V}:${$} - ${e}`):l.push(e)}return"string"===s?l.join("\n"):l}function searchVerse(e,t=!1,r=!1,i="indexed"){let n=[];const o=t?e:e.toLowerCase();for(let e in bibleData)for(let i in bibleData[e])for(let s in bibleData[e][i]){const a=bibleData[e][i][s],l=t?a:a.toLowerCase();let b;if(r){b=new RegExp(`\\b${o}\\b`,t?"":"i").test(l)}else b=-1!==l.indexOf(o);b&&n.push({key:`${e} ${i}:${s}`,book:e,chapter:i,verse:s,content:a})}return"string"===i?n.map((e=>`${e.book} ${e.chapter}:${e.verse} - ${e.content}`)).join("\n"):"indexed"===i?n:void 0}function resolveAbbreviation(e){return abbreviations[e]||e}function bibleStats(){return{books:Object.keys(bibleData).length,chapters:Object.values(bibleData).reduce(((e,t)=>e+Object.keys(t).length),0),verses:Object.values(bibleData).reduce(((e,t)=>e+Object.values(t).reduce(((e,t)=>e+t.length),0)),0)}}function bibleValidation(){return{isValidBook:isValidBook,isValidChapter:isValidChapter,isValidVerse:isValidVerse}} \ No newline at end of file diff --git a/dist/cjs/utils/abbreviations.js b/dist/cjs/utils/abbreviations.js index 15d1781..5849537 100644 --- a/dist/cjs/utils/abbreviations.js +++ b/dist/cjs/utils/abbreviations.js @@ -1,71 +1 @@ -"use strict"; -// @ts-ignore -const abbreviations = { - Gen: "Genesis", - Ex: "Exodus", - Lev: "Leviticus", - Num: "Numbers", - Deu: "Deuteronomy", - Jos: "Joshua", - Jdg: "Judges", - Rut: "Ruth", - "1Sa": "1 Samuel", - "2Sa": "2 Samuel", - "1Ki": "1 Kings", - "2Ki": "2 Kings", - "1Ch": "1 Chronicles", - "2Ch": "2 Chronicles", - Ezr: "Ezra", - Neh: "Nehemiah", - Est: "Esther", - Job: "Job", - Psa: "Psalms", - Pro: "Proverbs", - Ecc: "Ecclesiastes", - Sng: "Song of Solomon", - Isa: "Isaiah", - Jer: "Jeremiah", - Lam: "Lamentations", - Eze: "Ezekiel", - Dan: "Daniel", - Hos: "Hosea", - Joe: "Joel", - Amo: "Amos", - Oba: "Obadiah", - Jnh: "Jonah", - Mic: "Micah", - Nah: "Nahum", - Hab: "Habakkuk", - Zeph: "Zephaniah", - Hag: "Haggai", - Zech: "Zechariah", - Mal: "Malachi", - Matt: "Matthew", - Mark: "Mark", - Luk: "Luke", - Jhn: "John", - Act: "Acts", - Rom: "Romans", - "1Co": "1 Corinthians", - "2Co": "2 Corinthians", - Gal: "Galatians", - Eph: "Ephesians", - Phil: "Philippians", - Col: "Colossians", - "1Th": "1 Thessalonians", - "2Th": "2 Thessalonians", - "1Ti": "1 Timothy", - "2Ti": "2 Timothy", - Tit: "Titus", - Phm: "Philemon", - Heb: "Hebrews", - Jam: "James", - "1Pe": "1 Peter", - "2Pe": "2 Peter", - "1Jn": "1 John", - "2Jn": "2 John", - "3Jn": "3 John", - Jude: "Jude", - Rev: "Revelation", -}; -module.exports = abbreviations; +"use strict";const abbreviations={Gen:"Genesis",Ex:"Exodus",Lev:"Leviticus",Num:"Numbers",Deu:"Deuteronomy",Jos:"Joshua",Jdg:"Judges",Rut:"Ruth","1Sa":"1 Samuel","2Sa":"2 Samuel","1Ki":"1 Kings","2Ki":"2 Kings","1Ch":"1 Chronicles","2Ch":"2 Chronicles",Ezr:"Ezra",Neh:"Nehemiah",Est:"Esther",Job:"Job",Psa:"Psalms",Pro:"Proverbs",Ecc:"Ecclesiastes",Sng:"Song of Solomon",Isa:"Isaiah",Jer:"Jeremiah",Lam:"Lamentations",Eze:"Ezekiel",Dan:"Daniel",Hos:"Hosea",Joe:"Joel",Amo:"Amos",Oba:"Obadiah",Jnh:"Jonah",Mic:"Micah",Nah:"Nahum",Hab:"Habakkuk",Zeph:"Zephaniah",Hag:"Haggai",Zech:"Zechariah",Mal:"Malachi",Matt:"Matthew",Mark:"Mark",Luk:"Luke",Jhn:"John",Act:"Acts",Rom:"Romans","1Co":"1 Corinthians","2Co":"2 Corinthians",Gal:"Galatians",Eph:"Ephesians",Phil:"Philippians",Col:"Colossians","1Th":"1 Thessalonians","2Th":"2 Thessalonians","1Ti":"1 Timothy","2Ti":"2 Timothy",Tit:"Titus",Phm:"Philemon",Heb:"Hebrews",Jam:"James","1Pe":"1 Peter","2Pe":"2 Peter","1Jn":"1 John","2Jn":"2 John","3Jn":"3 John",Jude:"Jude",Rev:"Revelation"};module.exports=abbreviations; \ No newline at end of file diff --git a/dist/cjs/utils/validation.js b/dist/cjs/utils/validation.js index bd47b25..f2c1044 100644 --- a/dist/cjs/utils/validation.js +++ b/dist/cjs/utils/validation.js @@ -1,49 +1 @@ -"use strict"; -// @ts-ignore -const bibleData = require("../data/bible.json"); -/** - * Checks if the provided book name is a valid entry in the bibleData. - * - * @param {string} bookName - The name of the book to check. - * @return {boolean} Indicates whether the book name is valid. - */ -// @ts-ignore -function isValidBook(bookName) { - return bibleData.hasOwnProperty(bookName); -} -/** - * Checks if the given chapter number is valid for the specified book. - * - * @param {string} bookName - The name of the book. - * @param {number} chapterNumber - The number of the chapter. - * @return {boolean} Returns true if the chapter number is valid, false otherwise. - */ -// @ts-ignore -function isValidChapter(bookName, chapterNumber) { - if (!isValidBook(bookName)) { - return false; - } - const book = bibleData[bookName]; - return book.hasOwnProperty(chapterNumber); -} -/** - * Checks if the given verse number is valid for the specified book and chapter. - * - * @param {string} bookName - The name of the book. - * @param {number} chapterNumber - The number of the chapter. - * @param {number} verseNumber - The number of the verse. - * @return {boolean} Returns true if the verse number is valid, false otherwise. - */ -// @ts-ignore -function isValidVerse(bookName, chapterNumber, verseNumber) { - if (!isValidChapter(bookName, chapterNumber)) { - return false; - } - const chapter = bibleData[bookName][chapterNumber]; - return verseNumber >= 1 && verseNumber <= chapter.length; -} -module.exports = { - isValidBook, - isValidChapter, - isValidVerse, -}; +"use strict";const bibleData=require("../data/bible.json");function isValidBook(i){return bibleData.hasOwnProperty(i)}function isValidChapter(i,e){if(!isValidBook(i))return!1;return bibleData[i].hasOwnProperty(e)}function isValidVerse(i,e,a){if(!isValidChapter(i,e))return!1;const r=bibleData[i][e];return a>=1&&a<=r.length}module.exports={isValidBook:isValidBook,isValidChapter:isValidChapter,isValidVerse:isValidVerse}; \ No newline at end of file diff --git a/dist/esm/index.js b/dist/esm/index.js index 5850501..75def7b 100644 --- a/dist/esm/index.js +++ b/dist/esm/index.js @@ -1,366 +1 @@ -// @ts-ignore -const bibleData = require(`./data/bible.json`); -// @ts-ignore -const abbreviations = require(`./utils/abbreviations`); -const { -// @ts-ignore -isValidBook, -// @ts-ignore -isValidChapter, -// @ts-ignore -isValidVerse, } = require(`./utils/validation`); -/** - * 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. - * @deprecated The bible.json file no longer has translation markers, so this function is not needed. - */ -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"); - // Remove any '#' at the start of the verse - //cleanedVerse = cleanedVerse.replace(/^#\s*/, ""); - // Trim any extra whitespace - //cleanedVerse = cleanedVerse.trim(); - // Remove multiple spaces - //cleanedVerse = cleanedVerse.replace(/\s+/g, " "); - /* @end-deprecated */ - let cleanedVerse = verse; - if (outputType === "default" || outputType === "string") { - return cleanedVerse; - } - else if (outputType === "indexed") { - // Split the cleaned verse into words - const words = cleanedVerse.split(" "); - // Create an array of word objects - return words.map((word, index) => ({ - word: word, - index: index, - })); - } - else { - throw new Error("Invalid outputType. Use 'default' or 'indexed'."); - } -} -/** - * 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. - */ -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"); - } - let content = bibleData[bookName][chapterNumber][verseNumber - 1]; - if (cleanVerse) { - content = parseVerse(content, "string"); - } - if (outputType === "indexed") { - return [ - { - key: `${bookName} ${chapterNumber}:${verseNumber}`, - book: bookName, - chapter: chapterNumber.toString(), - verse: verseNumber.toString(), - content: content, - }, - ]; - } - else if (outputType === "string") { - return `${bookName} ${chapterNumber}:${verseNumber} - ${content}`; - } - else { - return [content]; - } -} -/** - * 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. - */ -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"); - } - const verses = bibleData[bookName][chapterNumber]; - if (outputType === "indexed") { - return verses.map((content, index) => ({ - key: `${bookName} ${chapterNumber}:${index + 1}`, - book: bookName, - chapter: chapterNumber.toString(), - verse: (index + 1).toString(), - content: cleanVerse ? parseVerse(content, "string") : content, - })); - } - else if (outputType === "string") { - return verses - .map((content, index) => `${bookName} ${chapterNumber}:${index + 1} - ${cleanVerse ? parseVerse(content, "string") : content}`) - .join("\n"); - } - else { - return verses; - } -} -/** - * 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. - */ -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"); - } - const chapters = bibleData[bookName]; - if (outputType === "indexed") { - return Object.entries(chapters).flatMap(([chapterNumber, verses]) => verses.map((content, index) => ({ - key: `${bookName} ${chapterNumber}:${index + 1}`, - book: bookName, - chapter: chapterNumber, - verse: (index + 1).toString(), - content: cleanVerse ? parseVerse(content, "string") : content, - }))); - } - else if (outputType === "string") { - return Object.entries(chapters) - .map(([chapterNumber, verses]) => verses - .map((content, index) => `${bookName} ${chapterNumber}:${index + 1} - ${cleanVerse ? parseVerse(content, "string") : content}`) - .join("\n")) - .join("\n\n"); - } - else { - return chapters; - } -} -/** - * 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. - */ -export function getChapterCount(bookName) { - if (!isValidBook(bookName)) { - throw new Error("Invalid book name"); - } - return Object.keys(bibleData[bookName]).length; -} -/** - * 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. - */ -export function getVerseCount(bookName, chapterNumber) { - if (!isValidChapter(bookName, chapterNumber)) { - throw new Error("Invalid chapter reference"); - } - return bibleData[bookName][chapterNumber].length; -} -/** - * Retrieves the list of Bible books. - * - * @return {Array} An array containing the names of all the Bible books. - */ -export function getBibleBooks() { - return Object.keys(bibleData); -} -/** - * 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, 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"); - } - var verses = []; - // Get the index of the start and end books - var startBookIndex = getBibleBooks().indexOf(startBookName); - var endBookIndex = getBibleBooks().indexOf(endBookName); - // Iterate through the books - for (var bookIndex = startBookIndex; bookIndex <= endBookIndex; bookIndex++) { - var bookName = getBibleBooks()[bookIndex]; - var startChapter = bookIndex === startBookIndex ? startChapterNumber : 1; - var endChapter = bookIndex === endBookIndex ? endChapterNumber : getChapterCount(bookName); - // Iterate through the chapters - for (var chapterNumber = startChapter; chapterNumber <= endChapter; chapterNumber++) { - var startVerse = bookIndex === startBookIndex && chapterNumber === startChapterNumber - ? startVerseNumber - : 1; - var endVerse = bookIndex === endBookIndex && chapterNumber === endChapterNumber - ? endVerseNumber - : getVerseCount(bookName, chapterNumber); - // Iterate through the verses - for (var verseNumber = startVerse; verseNumber <= endVerse; verseNumber++) { - let content = getVerse(bookName, chapterNumber, verseNumber)[0]; - if (cleanVerse) { - content = parseVerse(content, "string"); - } - if (outputType === "indexed") { - verses.push({ - key: `${bookName} ${chapterNumber}:${verseNumber}`, - book: bookName, - chapter: chapterNumber.toString(), - verse: verseNumber.toString(), - content: content, - }); - } - else if (outputType === "string") { - verses.push(`${bookName} ${chapterNumber}:${verseNumber} - ${content}`); - } - else { - verses.push(content); - } - } - } - } - if (outputType === "string") { - return verses.join("\n"); - } - else { - return verses; - } -} -/** - * 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. - */ -export function searchVerse(query, caseSensitive = false, exactMatch = false, outputType = "indexed") { - let searchResults = []; - // Normalize query based on case sensitivity - const normalizedQuery = caseSensitive ? query : query.toLowerCase(); - for (let book in bibleData) { - for (let chapter in bibleData[book]) { - for (let verse in bibleData[book][chapter]) { - const verseContent = bibleData[book][chapter][verse]; - const normalizedContent = caseSensitive - ? verseContent - : verseContent.toLowerCase(); - // Check for exact match or substring match - let matchCondition; - if (exactMatch) { - const regex = new RegExp(`\\b${normalizedQuery}\\b`, caseSensitive ? "" : "i"); - matchCondition = regex.test(normalizedContent); - } - else { - matchCondition = normalizedContent.indexOf(normalizedQuery) !== -1; - } - if (matchCondition) { - searchResults.push({ - key: `${book} ${chapter}:${verse}`, - book: book, - chapter: chapter, - verse: verse, - content: verseContent, - }); - } - } - } - } - if (outputType === "string") { - return searchResults - .map((result) => `${result.book} ${result.chapter}:${result.verse} - ${result.content}`) - .join("\n"); - } - else if (outputType === "indexed") { - return searchResults; - } -} -/** - * Resolves an abbreviation to its full name. - * - * @param {string} abbreviation - The abbreviation to resolve. - * @return {string} The full name corresponding to the 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. - */ -export function bibleStats() { - return { - books: Object.keys(bibleData).length, - chapters: Object.values(bibleData).reduce((sum, book) => sum + Object.keys(book).length, 0), - verses: Object.values(bibleData).reduce((sum, book) => sum + - Object.values(book).reduce((sum, chapter) => sum + chapter.length, 0), 0), - }; -} -/** - * Returns an object containing the three validation functions: `isValidBook`, `isValidChapter`, and `isValidVerse`. - * - * @return {Object} An object with the validation functions as properties. - */ -export function bibleValidation() { - return { - isValidBook, - isValidChapter, - isValidVerse, - }; -} -/* module.exports = { - getVerse, - getChapter, - getBook, - getRange, - getChapterCount, - getVerseCount, - getBibleBooks, - searchVerse, - parseVerse, - resolveAbbreviation, - bibleStats, - bibleValidation: { - ...validators(), - }, -}; */ +const bibleData=require("./data/bible.json"),abbreviations=require("./utils/abbreviations"),{isValidBook:isValidBook,isValidChapter:isValidChapter,isValidVerse:isValidVerse}=require("./utils/validation");export function parseVerse(e,t="default"){if("default"===t||"string"===t)return e;if("indexed"===t){return e.split(" ").map(((e,t)=>({word:e,index:t})))}throw new Error("Invalid outputType. Use 'default' or 'indexed'.")}export function getVerse(e,t,r,i="default",n=!0){if(!isValidVerse(e,t,r))throw new Error("Invalid verse reference");let o=bibleData[e][t][r-1];return n&&(o=parseVerse(o,"string")),"indexed"===i?[{key:`${e} ${t}:${r}`,book:e,chapter:t.toString(),verse:r.toString(),content:o}]:"string"===i?`${e} ${t}:${r} - ${o}`:[o]}export function getChapter(e,t,r="default",i=!0){if(!isValidChapter(e,t))throw new Error("Invalid chapter reference");const n=bibleData[e][t];return"indexed"===r?n.map(((r,n)=>({key:`${e} ${t}:${n+1}`,book:e,chapter:t.toString(),verse:(n+1).toString(),content:i?parseVerse(r,"string"):r}))):"string"===r?n.map(((r,n)=>`${e} ${t}:${n+1} - ${i?parseVerse(r,"string"):r}`)).join("\n"):n}export function getBook(e,t="default",r=!0){if(!isValidBook(e))throw new Error("Invalid book name");const i=bibleData[e];return"indexed"===t?Object.entries(i).flatMap((([t,i])=>i.map(((i,n)=>({key:`${e} ${t}:${n+1}`,book:e,chapter:t,verse:(n+1).toString(),content:r?parseVerse(i,"string"):i}))))):"string"===t?Object.entries(i).map((([t,i])=>i.map(((i,n)=>`${e} ${t}:${n+1} - ${r?parseVerse(i,"string"):i}`)).join("\n"))).join("\n\n"):i}export function getChapterCount(e){if(!isValidBook(e))throw new Error("Invalid book name");return Object.keys(bibleData[e]).length}export function getVerseCount(e,t){if(!isValidChapter(e,t))throw new Error("Invalid chapter reference");return bibleData[e][t].length}export function getBibleBooks(){return Object.keys(bibleData)}export function getRange(e,t,r,i,n,o,a="default",s=!0){if(!isValidVerse(e,t,r)||!isValidVerse(i,n,o))throw new Error("Invalid verse reference");for(var l=[],b=getBibleBooks().indexOf(e),d=getBibleBooks().indexOf(i),p=b;p<=d;p++)for(var u=getBibleBooks()[p],c=p===b?t:1,f=p===d?n:getChapterCount(u),g=c;g<=f;g++)for(var V=p===b&&g===t?r:1,$=p===d&&g===n?o:getVerseCount(u,g),h=V;h<=$;h++){let e=getVerse(u,g,h)[0];s&&(e=parseVerse(e,"string")),"indexed"===a?l.push({key:`${u} ${g}:${h}`,book:u,chapter:g.toString(),verse:h.toString(),content:e}):"string"===a?l.push(`${u} ${g}:${h} - ${e}`):l.push(e)}return"string"===a?l.join("\n"):l}export function searchVerse(e,t=!1,r=!1,i="indexed"){let n=[];const o=t?e:e.toLowerCase();for(let e in bibleData)for(let i in bibleData[e])for(let a in bibleData[e][i]){const s=bibleData[e][i][a],l=t?s:s.toLowerCase();let b;if(r){b=new RegExp(`\\b${o}\\b`,t?"":"i").test(l)}else b=-1!==l.indexOf(o);b&&n.push({key:`${e} ${i}:${a}`,book:e,chapter:i,verse:a,content:s})}return"string"===i?n.map((e=>`${e.book} ${e.chapter}:${e.verse} - ${e.content}`)).join("\n"):"indexed"===i?n:void 0}export function resolveAbbreviation(e){return abbreviations[e]||e}export function bibleStats(){return{books:Object.keys(bibleData).length,chapters:Object.values(bibleData).reduce(((e,t)=>e+Object.keys(t).length),0),verses:Object.values(bibleData).reduce(((e,t)=>e+Object.values(t).reduce(((e,t)=>e+t.length),0)),0)}}export function bibleValidation(){return{isValidBook:isValidBook,isValidChapter:isValidChapter,isValidVerse:isValidVerse}} \ No newline at end of file diff --git a/dist/esm/utils/abbreviations.js b/dist/esm/utils/abbreviations.js index 15d1781..5849537 100644 --- a/dist/esm/utils/abbreviations.js +++ b/dist/esm/utils/abbreviations.js @@ -1,71 +1 @@ -"use strict"; -// @ts-ignore -const abbreviations = { - Gen: "Genesis", - Ex: "Exodus", - Lev: "Leviticus", - Num: "Numbers", - Deu: "Deuteronomy", - Jos: "Joshua", - Jdg: "Judges", - Rut: "Ruth", - "1Sa": "1 Samuel", - "2Sa": "2 Samuel", - "1Ki": "1 Kings", - "2Ki": "2 Kings", - "1Ch": "1 Chronicles", - "2Ch": "2 Chronicles", - Ezr: "Ezra", - Neh: "Nehemiah", - Est: "Esther", - Job: "Job", - Psa: "Psalms", - Pro: "Proverbs", - Ecc: "Ecclesiastes", - Sng: "Song of Solomon", - Isa: "Isaiah", - Jer: "Jeremiah", - Lam: "Lamentations", - Eze: "Ezekiel", - Dan: "Daniel", - Hos: "Hosea", - Joe: "Joel", - Amo: "Amos", - Oba: "Obadiah", - Jnh: "Jonah", - Mic: "Micah", - Nah: "Nahum", - Hab: "Habakkuk", - Zeph: "Zephaniah", - Hag: "Haggai", - Zech: "Zechariah", - Mal: "Malachi", - Matt: "Matthew", - Mark: "Mark", - Luk: "Luke", - Jhn: "John", - Act: "Acts", - Rom: "Romans", - "1Co": "1 Corinthians", - "2Co": "2 Corinthians", - Gal: "Galatians", - Eph: "Ephesians", - Phil: "Philippians", - Col: "Colossians", - "1Th": "1 Thessalonians", - "2Th": "2 Thessalonians", - "1Ti": "1 Timothy", - "2Ti": "2 Timothy", - Tit: "Titus", - Phm: "Philemon", - Heb: "Hebrews", - Jam: "James", - "1Pe": "1 Peter", - "2Pe": "2 Peter", - "1Jn": "1 John", - "2Jn": "2 John", - "3Jn": "3 John", - Jude: "Jude", - Rev: "Revelation", -}; -module.exports = abbreviations; +"use strict";const abbreviations={Gen:"Genesis",Ex:"Exodus",Lev:"Leviticus",Num:"Numbers",Deu:"Deuteronomy",Jos:"Joshua",Jdg:"Judges",Rut:"Ruth","1Sa":"1 Samuel","2Sa":"2 Samuel","1Ki":"1 Kings","2Ki":"2 Kings","1Ch":"1 Chronicles","2Ch":"2 Chronicles",Ezr:"Ezra",Neh:"Nehemiah",Est:"Esther",Job:"Job",Psa:"Psalms",Pro:"Proverbs",Ecc:"Ecclesiastes",Sng:"Song of Solomon",Isa:"Isaiah",Jer:"Jeremiah",Lam:"Lamentations",Eze:"Ezekiel",Dan:"Daniel",Hos:"Hosea",Joe:"Joel",Amo:"Amos",Oba:"Obadiah",Jnh:"Jonah",Mic:"Micah",Nah:"Nahum",Hab:"Habakkuk",Zeph:"Zephaniah",Hag:"Haggai",Zech:"Zechariah",Mal:"Malachi",Matt:"Matthew",Mark:"Mark",Luk:"Luke",Jhn:"John",Act:"Acts",Rom:"Romans","1Co":"1 Corinthians","2Co":"2 Corinthians",Gal:"Galatians",Eph:"Ephesians",Phil:"Philippians",Col:"Colossians","1Th":"1 Thessalonians","2Th":"2 Thessalonians","1Ti":"1 Timothy","2Ti":"2 Timothy",Tit:"Titus",Phm:"Philemon",Heb:"Hebrews",Jam:"James","1Pe":"1 Peter","2Pe":"2 Peter","1Jn":"1 John","2Jn":"2 John","3Jn":"3 John",Jude:"Jude",Rev:"Revelation"};module.exports=abbreviations; \ No newline at end of file diff --git a/dist/esm/utils/validation.js b/dist/esm/utils/validation.js index bd47b25..f2c1044 100644 --- a/dist/esm/utils/validation.js +++ b/dist/esm/utils/validation.js @@ -1,49 +1 @@ -"use strict"; -// @ts-ignore -const bibleData = require("../data/bible.json"); -/** - * Checks if the provided book name is a valid entry in the bibleData. - * - * @param {string} bookName - The name of the book to check. - * @return {boolean} Indicates whether the book name is valid. - */ -// @ts-ignore -function isValidBook(bookName) { - return bibleData.hasOwnProperty(bookName); -} -/** - * Checks if the given chapter number is valid for the specified book. - * - * @param {string} bookName - The name of the book. - * @param {number} chapterNumber - The number of the chapter. - * @return {boolean} Returns true if the chapter number is valid, false otherwise. - */ -// @ts-ignore -function isValidChapter(bookName, chapterNumber) { - if (!isValidBook(bookName)) { - return false; - } - const book = bibleData[bookName]; - return book.hasOwnProperty(chapterNumber); -} -/** - * Checks if the given verse number is valid for the specified book and chapter. - * - * @param {string} bookName - The name of the book. - * @param {number} chapterNumber - The number of the chapter. - * @param {number} verseNumber - The number of the verse. - * @return {boolean} Returns true if the verse number is valid, false otherwise. - */ -// @ts-ignore -function isValidVerse(bookName, chapterNumber, verseNumber) { - if (!isValidChapter(bookName, chapterNumber)) { - return false; - } - const chapter = bibleData[bookName][chapterNumber]; - return verseNumber >= 1 && verseNumber <= chapter.length; -} -module.exports = { - isValidBook, - isValidChapter, - isValidVerse, -}; +"use strict";const bibleData=require("../data/bible.json");function isValidBook(i){return bibleData.hasOwnProperty(i)}function isValidChapter(i,e){if(!isValidBook(i))return!1;return bibleData[i].hasOwnProperty(e)}function isValidVerse(i,e,a){if(!isValidChapter(i,e))return!1;const r=bibleData[i][e];return a>=1&&a<=r.length}module.exports={isValidBook:isValidBook,isValidChapter:isValidChapter,isValidVerse:isValidVerse}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d182f0c..b9172b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "best-bible", - "version": "1.6.4", + "version": "1.6.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "best-bible", - "version": "1.6.4", + "version": "1.6.5", "license": "GPL-3.0-or-later", "devDependencies": { "@types/node": "^22.5.5", @@ -14,6 +14,7 @@ "esm": "^3.2.25", "fs": "^0.0.1-security", "path": "^0.12.7", + "terser": "^5.34.1", "typescript": "^5.6.2" } }, @@ -425,6 +426,70 @@ "node": ">=18" } }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.6.tgz", + "integrity": "sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, "node_modules/@types/node": { "version": "22.7.4", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.4.tgz", @@ -435,6 +500,33 @@ "undici-types": "~6.19.2" } }, + "node_modules/acorn": { + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "license": "MIT" + }, "node_modules/esbuild": { "version": "0.24.0", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.24.0.tgz", @@ -520,6 +612,46 @@ "node": ">= 0.6.0" } }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/terser": { + "version": "5.34.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.34.1.tgz", + "integrity": "sha512-FsJZ7iZLd/BXkz+4xrRTGJ26o/6VTjQytUk8b8OxkwcD2I+79VPJlz7qss1+zE7h8GNIScFqXcDyJ/KqBYZFVA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.8.2", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/typescript": { "version": "5.6.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", diff --git a/package.json b/package.json index 418e262..5f290b1 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,14 @@ { "name": "best-bible", - "version": "1.6.4", + "version": "1.6.5", "description": "Fetch, parse, and analyze the Bible easily with JavaScript", "scripts": { "build:cjs": "tsc --project tsconfig.cjs.json || true && mkdir -p dist/cjs/data && cp src/data/bible.json dist/cjs/data/", "build:esm": "tsc --project tsconfig.esm.json || true && mkdir -p dist/esm/data && cp src/data/bible.json dist/esm/data/", "build:browser": "esbuild src/browser.ts --bundle --minify --sourcemap --format=iife --platform=browser --target=es2015 --outfile=dist/browser/best-bible.min.js", - "build": "npm run build:cjs && npm run build:esm && npm run build:browser", + "minify:cjs": "find dist/cjs -name '*.js' -type f -exec terser {} --compress --mangle --output {} \\;", + "minify:esm": "find dist/esm -name '*.js' -type f -exec terser {} --compress --mangle --output {} \\;", + "build": "npm run build:cjs && npm run build:esm && npm run build:browser && npm run minify:cjs && npm run minify:esm", "prepublishOnly": "npm run build" }, "files": [ @@ -51,6 +53,7 @@ "esm": "^3.2.25", "fs": "^0.0.1-security", "path": "^0.12.7", + "terser": "^5.34.1", "typescript": "^5.6.2" } }