codexparser 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +94 -2
- package/RELEASE_NOTES_v0.4.0.md +94 -0
- package/package.json +11 -1
- package/src/core/CodexParser.js +21 -0
- package/src/core/ReferenceParser.js +129 -26
- package/src/data/chapter_verses/daniel.js +4 -0
- package/src/data/chapter_verses/esther.js +12 -1
- package/src/data/lxx-editions.js +58 -0
- package/src/data/versifications/1samuel.js +1 -1
- package/src/data/versifications/2kings.js +117 -0
- package/src/data/versifications/2samuel.js +1 -1
- package/src/data/versifications/daniel.js +28 -0
- package/src/data/versifications/esther.js +114 -0
- package/src/data/versifications/ezekiel.js +37 -37
- package/src/data/versifications/genesis.js +37 -39
- package/src/data/versifications/micah.js +19 -16
- package/src/data/versifications/numbers.js +83 -1
- package/src/data/versifications/psalms.js +12 -12
- package/src/data/versified.js +6 -1
- package/.trunk/configs/.markdownlint.yaml +0 -2
- package/.trunk/trunk.yaml +0 -32
- package/REFACTORING.md +0 -214
- package/RELEASE_NOTES_v0.2.0.md +0 -5
- package/RELEASE_NOTES_v0.3.0.md +0 -32
- package/bibles/kjv.json +0 -194080
- package/bibles/updated_kjv.json +0 -194080
- package/passage-generator.js +0 -25
- package/src/CodexParser.js.backup +0 -1713
package/REFACTORING.md
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
# CodexParser Refactoring Summary
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The CodexParser codebase has been modernized and refactored to follow current JavaScript best practices and improve code maintainability through separation of concerns.
|
|
6
|
-
|
|
7
|
-
## Key Improvements
|
|
8
|
-
|
|
9
|
-
### 1. **Modern ES6+ Features**
|
|
10
|
-
- **Private fields** using `#` syntax for true encapsulation
|
|
11
|
-
- **Class-based architecture** with clear separation of responsibilities
|
|
12
|
-
- **Getter/setter** accessors for backward compatibility
|
|
13
|
-
- **Arrow functions** where appropriate
|
|
14
|
-
- **Const/let** instead of var
|
|
15
|
-
- **Template literals** for string formatting
|
|
16
|
-
- **Destructuring** for cleaner code
|
|
17
|
-
- **Static methods** for utility functions
|
|
18
|
-
|
|
19
|
-
### 2. **Separation of Concerns**
|
|
20
|
-
|
|
21
|
-
The monolithic 1,658-line `CodexParser.js` file has been split into focused, single-responsibility modules:
|
|
22
|
-
|
|
23
|
-
#### **ScriptureScanner.js** (~230 lines)
|
|
24
|
-
- Handles text scanning for scripture references
|
|
25
|
-
- Private methods for validation and detection
|
|
26
|
-
- Uses ES6+ private fields (`#`)
|
|
27
|
-
- Focused solely on finding references in text
|
|
28
|
-
|
|
29
|
-
#### **ReferenceParser.js** (~450 lines)
|
|
30
|
-
- Parses found references into structured objects
|
|
31
|
-
- Handles all reference types (single verse, ranges, multi-chapter, etc.)
|
|
32
|
-
- Private helper methods for each parsing scenario
|
|
33
|
-
- Clean API for passage population
|
|
34
|
-
|
|
35
|
-
#### **PassageUtils.js** (~120 lines)
|
|
36
|
-
- Static utility class for passage manipulation
|
|
37
|
-
- Handles verse expansion, range merging
|
|
38
|
-
- Chapter/verse formatting
|
|
39
|
-
- Reusable across the codebase
|
|
40
|
-
|
|
41
|
-
#### **PassageValidator.js** (~100 lines)
|
|
42
|
-
- Validates scripture passages
|
|
43
|
-
- Error code constants
|
|
44
|
-
- Clear validation logic
|
|
45
|
-
- Separate from parsing concerns
|
|
46
|
-
|
|
47
|
-
#### **VersionHandler.js** (~75 lines)
|
|
48
|
-
- Manages Bible version logic
|
|
49
|
-
- Version normalization
|
|
50
|
-
- Version object creation
|
|
51
|
-
- Clean version constants
|
|
52
|
-
|
|
53
|
-
#### **VersificationHandler.js** (~140 lines)
|
|
54
|
-
- Handles versification differences between versions
|
|
55
|
-
- LXX/MT/English version mapping
|
|
56
|
-
- Separate from core parsing logic
|
|
57
|
-
|
|
58
|
-
#### **PassageCollection.js** (~300 lines)
|
|
59
|
-
- Extends Array with scripture-specific methods
|
|
60
|
-
- Chainable utility methods (`first()`, `oldTestament()`, `newTestament()`)
|
|
61
|
-
- Version conversion (`getVersion()`)
|
|
62
|
-
- Passage combination logic
|
|
63
|
-
- Immutable operations
|
|
64
|
-
|
|
65
|
-
#### **CodexParser.js** (Now ~340 lines, down from 1,658!)
|
|
66
|
-
- Orchestrates all the components
|
|
67
|
-
- Clean, focused public API
|
|
68
|
-
- Private fields for internal state
|
|
69
|
-
- Legacy compatibility maintained
|
|
70
|
-
|
|
71
|
-
## Architecture Benefits
|
|
72
|
-
|
|
73
|
-
### Before
|
|
74
|
-
```
|
|
75
|
-
CodexParser.js (1,658 lines)
|
|
76
|
-
├── Scanning logic
|
|
77
|
-
├── Parsing logic
|
|
78
|
-
├── Validation logic
|
|
79
|
-
├── Versification logic
|
|
80
|
-
├── Utility methods
|
|
81
|
-
├── Version handling
|
|
82
|
-
└── Collection methods
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### After
|
|
86
|
-
```
|
|
87
|
-
CodexParser.js (340 lines) - Orchestrator
|
|
88
|
-
├── ScriptureScanner.js - Text scanning
|
|
89
|
-
├── ReferenceParser.js - Reference parsing
|
|
90
|
-
├── PassageValidator.js - Validation
|
|
91
|
-
├── VersificationHandler.js - Version differences
|
|
92
|
-
├── VersionHandler.js - Version management
|
|
93
|
-
├── PassageUtils.js - Utility functions
|
|
94
|
-
└── PassageCollection.js - Collection operations
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## Backward Compatibility
|
|
98
|
-
|
|
99
|
-
All existing public APIs have been preserved:
|
|
100
|
-
- ✅ `scan(text)` - Still works
|
|
101
|
-
- ✅ `parse(reference)` - Still works
|
|
102
|
-
- ✅ `getPassages()` - Still works
|
|
103
|
-
- ✅ `combine()` - Still works
|
|
104
|
-
- ✅ `first()` - Still works
|
|
105
|
-
- ✅ `bookify()` - Still works
|
|
106
|
-
- ✅ Legacy getters/setters maintained
|
|
107
|
-
- ✅ Public properties maintained for compatibility
|
|
108
|
-
|
|
109
|
-
## Code Quality Improvements
|
|
110
|
-
|
|
111
|
-
### Encapsulation
|
|
112
|
-
- Private fields (`#scanner`, `#parser`, etc.) prevent external modification
|
|
113
|
-
- Internal state is properly hidden
|
|
114
|
-
- Clear public vs private API distinction
|
|
115
|
-
|
|
116
|
-
### Single Responsibility
|
|
117
|
-
- Each class has one clear purpose
|
|
118
|
-
- Easier to test individual components
|
|
119
|
-
- Easier to maintain and update
|
|
120
|
-
|
|
121
|
-
### Reusability
|
|
122
|
-
- Utility classes can be used independently
|
|
123
|
-
- Static methods for common operations
|
|
124
|
-
- Modular design allows component reuse
|
|
125
|
-
|
|
126
|
-
### Testability
|
|
127
|
-
- Each module can be tested in isolation
|
|
128
|
-
- Smaller, focused units are easier to test
|
|
129
|
-
- Clear dependencies make mocking easier
|
|
130
|
-
|
|
131
|
-
### Maintainability
|
|
132
|
-
- Smaller files are easier to navigate
|
|
133
|
-
- Clear file organization
|
|
134
|
-
- Better code discoverability
|
|
135
|
-
- Easier onboarding for new developers
|
|
136
|
-
|
|
137
|
-
## File Structure
|
|
138
|
-
|
|
139
|
-
```
|
|
140
|
-
src/
|
|
141
|
-
├── CodexParser.js # Main orchestrator class (340 lines)
|
|
142
|
-
├── ScriptureScanner.js # Text scanning (230 lines)
|
|
143
|
-
├── ReferenceParser.js # Reference parsing (450 lines)
|
|
144
|
-
├── PassageValidator.js # Validation logic (100 lines)
|
|
145
|
-
├── VersificationHandler.js # Versification handling (140 lines)
|
|
146
|
-
├── VersionHandler.js # Version management (75 lines)
|
|
147
|
-
├── PassageUtils.js # Utility functions (120 lines)
|
|
148
|
-
├── PassageCollection.js # Collection class (300 lines)
|
|
149
|
-
├── abbr.js # Abbreviations data
|
|
150
|
-
├── bible.js # Bible book data
|
|
151
|
-
├── functions.js # Legacy functions
|
|
152
|
-
├── regex.js # Regex patterns
|
|
153
|
-
├── toc.js # Table of contents
|
|
154
|
-
└── versified.js # Versification data
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## Performance Considerations
|
|
158
|
-
|
|
159
|
-
- No performance degradation from refactoring
|
|
160
|
-
- Same algorithms, better organized
|
|
161
|
-
- Lazy initialization where appropriate
|
|
162
|
-
- Efficient use of private fields
|
|
163
|
-
|
|
164
|
-
## Migration Guide
|
|
165
|
-
|
|
166
|
-
### For Developers Using CodexParser
|
|
167
|
-
|
|
168
|
-
**No changes needed!** The refactoring maintains 100% backward compatibility.
|
|
169
|
-
|
|
170
|
-
```javascript
|
|
171
|
-
// All existing code continues to work
|
|
172
|
-
const CodexParser = require('./src/core/CodexParser');
|
|
173
|
-
const parser = new CodexParser();
|
|
174
|
-
parser.parse('John 3:16').getPassages();
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### For Developers Extending CodexParser
|
|
178
|
-
|
|
179
|
-
New modular structure makes it easier to:
|
|
180
|
-
- Add new reference types (extend ReferenceParser)
|
|
181
|
-
- Add new validation rules (extend PassageValidator)
|
|
182
|
-
- Add new utility methods (add to PassageUtils)
|
|
183
|
-
- Support new versions (extend VersionHandler)
|
|
184
|
-
|
|
185
|
-
## Testing
|
|
186
|
-
|
|
187
|
-
All existing tests pass without modification:
|
|
188
|
-
- ✅ quicktest.js
|
|
189
|
-
- ✅ single.js
|
|
190
|
-
- ✅ combine.js
|
|
191
|
-
- ✅ All other existing tests
|
|
192
|
-
|
|
193
|
-
## Future Enhancements Made Easier
|
|
194
|
-
|
|
195
|
-
The new structure makes these enhancements straightforward:
|
|
196
|
-
|
|
197
|
-
1. **Add TypeScript support** - Clear interfaces from class structure
|
|
198
|
-
2. **Add more Bible versions** - Isolated in VersionHandler
|
|
199
|
-
3. **Improve validation** - Isolated in PassageValidator
|
|
200
|
-
4. **Add new reference formats** - Extend ReferenceParser
|
|
201
|
-
5. **Performance optimization** - Target specific modules
|
|
202
|
-
6. **Add caching** - Can be added to specific components
|
|
203
|
-
|
|
204
|
-
## Summary
|
|
205
|
-
|
|
206
|
-
This refactoring transforms a large, monolithic class into a well-organized, modern JavaScript codebase that:
|
|
207
|
-
- ✅ Follows SOLID principles
|
|
208
|
-
- ✅ Uses modern ES6+ features
|
|
209
|
-
- ✅ Maintains complete backward compatibility
|
|
210
|
-
- ✅ Improves code organization and maintainability
|
|
211
|
-
- ✅ Makes future enhancements easier
|
|
212
|
-
- ✅ Provides better developer experience
|
|
213
|
-
|
|
214
|
-
The codebase is now easier to understand, test, maintain, and extend while preserving all existing functionality.
|
package/RELEASE_NOTES_v0.2.0.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# CodexParser 0.2.0
|
|
2
|
-
|
|
3
|
-
Refactor into core/utils/format/data; OSIS textual hashes (e.g., John.3.16); pythonbible-style integer verse IDs for `osisNumeric`; per-passage version helpers (`getVersion/getLXX/getMT/getBHS/getEnglish`); dependency cleanup and audit fix; published to npm as `codexparser@0.2.0`.
|
|
4
|
-
|
|
5
|
-
See detailed notes in README under "Release Notes" → 0.2.0.
|
package/RELEASE_NOTES_v0.3.0.md
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# CodexParser 0.3.0
|
|
2
|
-
|
|
3
|
-
Added `convertVersion(targetVersion)` method on passage objects for versification conversion.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **New Method**: `passage.convertVersion(targetVersion)` accepts version string (`"eng"`, `"lxx"`, `"mt"`, or `"bhs"`).
|
|
8
|
-
- **Smart Conversion**: Automatically converts chapter/verse references between versifications when versification data exists (e.g., Psalms, Zechariah).
|
|
9
|
-
- **Fallback Behavior**: Returns same reference with updated version metadata if no versification exists (e.g., NT passages).
|
|
10
|
-
- **Tested**: Verified with Psalms, Zechariah, and NT passages.
|
|
11
|
-
|
|
12
|
-
## Usage Example
|
|
13
|
-
|
|
14
|
-
```javascript
|
|
15
|
-
const CodexParser = require("codexparser")
|
|
16
|
-
const parser = new CodexParser()
|
|
17
|
-
|
|
18
|
-
// Convert English reference to LXX
|
|
19
|
-
const [p] = parser.parse("Psalm 4:5").getPassages()
|
|
20
|
-
console.log(p.scripture.hash) // "Ps.4.5"
|
|
21
|
-
|
|
22
|
-
const lxx = p.convertVersion("lxx")
|
|
23
|
-
console.log(lxx.scripture.hash) // "Ps.4.6"
|
|
24
|
-
|
|
25
|
-
// No versification (NT) - returns same reference
|
|
26
|
-
const [j] = parser.parse("John 3:16").getPassages()
|
|
27
|
-
const jLxx = j.convertVersion("lxx")
|
|
28
|
-
console.log(jLxx.scripture.hash) // "John.3.16" (same)
|
|
29
|
-
console.log(jLxx.version.abbreviation) // "lxx" (version updated)
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
See full CHANGELOG: https://github.com/jeremyam/CodexParser/blob/main/CHANGELOG.md
|