Implements all three parser performance optimizations from issue #9:
Regex pre-compilation: All regex patterns in parser.js (~50) and jsonRepair.js (14) are now module-level constants instead of being compiled on every function call.
Format detection caching: Added lastDetectedFormat cache with hit threshold (3 consecutive hits) to skip redundant format checks on subsequent calls. Exported clearFormatCache() for cache invalidation.
Thinking tag removal: Already happens early in the pipeline before parsing (unchanged, confirmed optimal).
Tests: 33/33 passing. Covers repairJSON, extractJSONFromText, validateJSONSchema, safeParseJSON, all parser regex patterns, format cache logic, and performance comparison.
Implements all three parser performance optimizations from issue #9:
1. **Regex pre-compilation**: All regex patterns in parser.js (~50) and jsonRepair.js (14) are now module-level constants instead of being compiled on every function call.
2. **Format detection caching**: Added `lastDetectedFormat` cache with hit threshold (3 consecutive hits) to skip redundant format checks on subsequent calls. Exported `clearFormatCache()` for cache invalidation.
3. **Thinking tag removal**: Already happens early in the pipeline before parsing (unchanged, confirmed optimal).
Tests: 33/33 passing. Covers repairJSON, extractJSONFromText, validateJSONSchema, safeParseJSON, all parser regex patterns, format cache logic, and performance comparison.
Closes #9
- Pre-compile all regex patterns as module-level constants in parser.js and jsonRepair.js
- Add format detection caching (lastDetectedFormat, formatCacheHits) to skip redundant checks
- Add clearFormatCache() export for cache invalidation
- Add comprehensive test suite (33 tests) for parser and jsonRepair modules
- Fix regex escaping in dynamic patterns (statRegex, fieldRegex)
- Improve toFieldKey() regex specificity
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Implements all three parser performance optimizations from issue #9:
Regex pre-compilation: All regex patterns in parser.js (~50) and jsonRepair.js (14) are now module-level constants instead of being compiled on every function call.
Format detection caching: Added
lastDetectedFormatcache with hit threshold (3 consecutive hits) to skip redundant format checks on subsequent calls. ExportedclearFormatCache()for cache invalidation.Thinking tag removal: Already happens early in the pipeline before parsing (unchanged, confirmed optimal).
Tests: 33/33 passing. Covers repairJSON, extractJSONFromText, validateJSONSchema, safeParseJSON, all parser regex patterns, format cache logic, and performance comparison.
Closes #9
✅ No issues found — changes look consistent with the stated intent. Ready to be merged.