|
Asper Header
1.0.14
The header injector extension
|
Universal JSONC parser loader with dual module system support. More...
Go to the source code of this file.
Functions | |
| function async | loadJsoncParser () |
| Loads the jsonc-parser module with automatic fallback between module systems. | |
| function async | parseJsonFile (jsonContent:string) |
| Parses JSONC content with comprehensive error handling and validation. | |
Variables | |
| import | type { ParseError } from 'jsonc-parser' |
Universal JSONC parser loader with dual module system support.
This utility module provides robust JSONC (JSON with Comments) parsing capabilities with automatic fallback between CommonJS and ES Module loading systems. It ensures compatibility across different execution environments including VS Code extensions, Node.js applications, and modern ES Module test runners.
Key Features:
Loading Strategy:
Use Cases:
Definition in file jsoncLoader.ts.
| function async loadJsoncParser | ( | ) |
Loads the jsonc-parser module with automatic fallback between module systems.
| Error | if both CommonJS and ES Module loading fail |
Implements a robust dual-loading strategy to ensure jsonc-parser module availability across different JavaScript execution environments. This function handles the complexity of module system differences transparently.
Loading Strategy:
Environment Compatibility:
Error Handling: If CommonJS require() fails (typically in pure ES Module environments), the function automatically attempts dynamic import(). If both methods fail, the original error is propagated to the caller for appropriate handling.
Performance Characteristics:
Definition at line 65 of file jsoncLoader.ts.
| function async parseJsonFile | ( | jsonContent:string | ) |
Parses JSONC content with comprehensive error handling and validation.
| jsonContent | Raw JSONC string content to parse |
| Error | with detailed parse error information if parsing fails |
Provides a high-level interface for parsing JSONC (JSON with Comments) content with robust error handling and detailed error reporting. This function handles the complexity of error collection and provides meaningful error messages.
JSONC Features Supported:
Error Handling Strategy:
Usage Examples:
Performance Considerations:
Definition at line 121 of file jsoncLoader.ts.
| import type { ParseError } from 'jsonc-parser' |
Definition at line 34 of file jsoncLoader.ts.