UNPKG

awoken-bible-reference

Version:

Bible verse reference parser, generator and manipulator

101 lines (100 loc) 2.84 kB
/** * A Versification represents the way in which the bible text is split into * books, chapters and verses * * This module exports both a type decleration, and the default data set */ import BibleRef from './BibleRef'; /** * Minimal data set used to create full BookMeta * @private */ export interface BookMetaRaw { /** * 4 character USFM identifier, in upper case */ id: string; /** * Shortened book name used in osis references */ osisId: string; /** * Canconical, long form, name */ name: string; /** * Common aliases/abbreviations */ aliases: string[]; /** * Array of the number of verses in each chapter * Number of chapters in the book is implied by the length of this array */ verse_counts: number[]; } export interface ChapterMeta { /** * Number of verses within this chapter */ verse_count: number; /** * The cumulative number of verses between the beginning of the versification * and the first verse of this chapter */ cumulative_verse: number; } export interface BookMeta { id: string; osisId: string; name: string; index: number; aliases: string[]; chapters: ChapterMeta[]; [index: number]: ChapterMeta; } /** * A range alias is a regex pattern which denotes a named BibleRef set * Eg, these should parse equivalently: * - "Gospels" 'Mat-Jhn' * - "Old Testament" = 'Gen-Mal' */ interface RangeAlias { pattern: RegExp; refs: BibleRef[]; } /** * Argument that can be used to create a RangeAlias using just a compact * [book,book] representation for full book ranges where the books are used * as an argument to makeBookRange * * (this is primarily used in the createVersification arguments to make * the hard coded data we need to store both smaller (good for browser bundle) * and more compatible with versifications with different verse number divisions * (as we don't duplicate data about chapter/verse count inside a raw refs array) */ declare type RangeAliasRaw = RangeAlias | { pattern: RegExp; books: ([string, string] | [string])[]; }; export interface Versification { /** * Array of books within this Versification scheme */ order: BookMeta[]; /** * Mapping from book ID (eg GEN, REV) to the corresponding * element of the order array */ book: { [index: string]: BookMeta; }; /** Set of aliases that map onto cross-book ranges */ rangeAliases: RangeAlias[]; } /** * Creates a full Versification object from the minimal data set by computing * the rest */ export declare function createVersification(data: BookMetaRaw[], rangeAliases?: RangeAliasRaw[]): Versification; export declare const VERSIFICATION: Versification; export default VERSIFICATION;