mirror of
https://github.com/pupperpowell/bibdle.git
synced 2026-02-04 10:54:44 -05:00
Version 1
This commit is contained in:
23
src/lib/server/bible.ts
Normal file
23
src/lib/server/bible.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { BibleBook, Testament, BibleSection } from '$lib/types/bible';
|
||||
import { bibleBooks } from '$lib/types/bible';
|
||||
|
||||
export function getBookById(id: string): BibleBook | undefined {
|
||||
return bibleBooks.find((book) => book.id === id);
|
||||
}
|
||||
|
||||
export function getBooksByTestament(testament: Testament): BibleBook[] {
|
||||
return bibleBooks.filter((book) => book.testament === testament);
|
||||
}
|
||||
|
||||
export function getBooksBySection(section: BibleSection): BibleBook[] {
|
||||
return bibleBooks.filter((book) => book.section === section);
|
||||
}
|
||||
|
||||
export function isAdjacent(bookId1: string, bookId2: string): boolean {
|
||||
const book1 = getBookById(bookId1);
|
||||
const book2 = getBookById(bookId2);
|
||||
if (!book1 || !book2) return false;
|
||||
return Math.abs(book1.order - book2.order) === 1;
|
||||
}
|
||||
|
||||
export { bibleBooks };
|
||||
Reference in New Issue
Block a user