Skip to content

Commit

Permalink
Merge pull request #9 from BibleBytes/update-ids
Browse files Browse the repository at this point in the history
Update Bible IDs
  • Loading branch information
SellersEvan authored Oct 1, 2024
2 parents c723b5b + 4a93fd4 commit de21106
Show file tree
Hide file tree
Showing 4 changed files with 293 additions and 144 deletions.
52 changes: 37 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
## Installation
To install the package via npm, run:
```bash
npm install bible-reference-index
npm i @biblebytes/bible-reference
```


Expand Down Expand Up @@ -86,6 +86,10 @@ providing their standard ID/abbreviations according to the
The `Reference` class is the main component of this package, allowing you to
create and validate Bible references.

Reference ID strings can use a mix of delimiter between sections
(`\s`, `-`, `.`, `:`, `,`) for example, `EXO 2:5-10`, `EXO:2:5:10`,
and `EXO-2:5-10` are all treated the same.

```typescript
import { Reference, Language } from 'bible-reference-index';

Expand All @@ -97,9 +101,17 @@ console.log(ref1.toString()); // Output: "GEN:1:1"
const ref2 = new Reference(Language.English, "EXO 2:5-10");
console.log(ref2.toString(true)); // Output: "Exodus 2:5-10"

// Creating a reference with mixed delimiters
const ref3 = new Reference(Language.English, "EXO:2:5:10");
console.log(ref3.toString(true)); // Output: "Exodus 2:5-10"

// Setting a new reference
ref1.Set("MAT 5:9");
console.log(ref1.toString()); // Output: "MAT:5:9"

// Setting a reference, mixed delimiters
ref1.Set("MAT.5.9");
console.log(ref1.toString()); // Output: "MAT:5:9"
```


Expand All @@ -113,11 +125,11 @@ class Reference {
public book: Book;
public chapter: number;
public verse: number;
public chapterEnd?: number;
public verseEnd?: number;

constructor(language: Language, reference?: string);
public Set(reference: string): void;
public IsValid(): boolean;
public GetError(): string | undefined;
public toString(pretty?: boolean): string;
}
Expand All @@ -130,7 +142,7 @@ class Reference {
### Methods

#### constructor
Creates an instance of `Reference`.
Creates an instance of `Reference`. Throws error if invalid verse.

```typescript
constructor(language: Language, reference?: string)
Expand All @@ -142,16 +154,21 @@ constructor(language: Language, reference?: string)
**Examples**:
```typescript
const ref1 = new Reference(Language.English, "GEN 1:1");
const ref2 = new Reference(Language.English, "EXO 2:5-10");
const ref3 = new Reference(Language.English, "PSM 23:1-6");
const ref2 = new Reference(Language.English, "PSM 23:1-6");
const ref3 = new Reference(Language.English, "EXO 2:5-3:10");

// using any delimiter or mix of delimiters
const ref4 = new Reference(Language.English, "EXO:2:5:3:10");
const ref4 = new Reference(Language.English, "EXO-2-5-3-10");
```


<br/>


#### Set
Sets the reference details by parsing the reference string.
Sets the reference details by parsing the reference string. Throws error if
invalid verse.

```typescript
public Set(reference: string): void
Expand All @@ -164,31 +181,36 @@ public Set(reference: string): void
const ref = new Reference(Language.English);
ref.Set("MAT 5:9");
ref.Set("REV 21:3-4");

// using any delimiter or mix of delimiters
ref.Set("MAT:5:9");
ref.Set("REV:21:3-4");
```


<br/>


#### IsValid
Checks if the reference is valid. It ensures the verse and end of the verse
#### GetError
Checks if the reference is valid and returns the error as a string if the
verse is invalid. For example, this ensures the verse and end of the verse
range are valid.

```typescript
public IsValid(): boolean
public GetError(): string | undefined
```

- **Returns**: `true` if the reference is valid, otherwise `false`.
- **Returns**: `undefined` if the reference is valid, otherwise returns a string.

**Examples**:
```typescript
const ref = new Reference(Language.English);
ref.Set("MAT 5:9");
ref.IsValid(); // true
ref.GetError(); // undefined
ref.Set("MAT 5:1000");
ref.IsValid(); // false
ref.GetError(); // "Invalid verse number"
ref.Set("MAT 5:9-8");
ref.IsValid(); // false
ref.GetError(); // "Invalid verse end number"
```


Expand Down Expand Up @@ -358,7 +380,7 @@ Testament. Each book is represented by its abbreviation as defined in the
`Book` enum.

```typescript
const Books = [
const BooksOldTestament = [
Book.GEN,
Book.EXO,
// ... other books
Expand All @@ -376,7 +398,7 @@ Testament. Each book is represented by its abbreviation as defined in the
`Book` enum.

```typescript
const Books = [
const BooksNewTestament = [
Book.MAT,
Book.MRK,
// ... other books
Expand Down
2 changes: 1 addition & 1 deletion resources/languages/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const Metadata_EN = Define([
chapters: [18, 26, 22, 16, 20, 12, 29, 17, 18, 20, 10, 14],
},
{
name: "Song of Solomon",
name: "Song of Songs",
chapters: [17, 17, 11, 16, 16, 13, 13, 14],
},
{
Expand Down
Loading

0 comments on commit de21106

Please sign in to comment.