docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A utility that processes multiple JavaScript files to extract CommonJS export information with optimal performance.
You need to build a utility that analyzes JavaScript source code to extract CommonJS export information.
The utility should be optimized for parsing performance, especially when analyzing multiple files sequentially.
/**
* Analyzes JavaScript source code and extracts CommonJS export information.
*
* @param {string} sourceCode - JavaScript source code to analyze
* @returns {Promise<ExportInfo>} Export information or error details
*
* @typedef {Object} ExportInfo
* @property {string[]} exports - Array of named exports found in the code
* @property {string[]} reexports - Array of module specifiers that are reexported
* @property {ParseError|null} error - Error information if parsing failed, null otherwise
*
* @typedef {Object} ParseError
* @property {string} message - Error message
* @property {number} line - Line number where error occurred
* @property {number} column - Column number where error occurred
*/
async function analyzeModule(sourceCode) {
// IMPLEMENTATION HERE
}
module.exports = {
analyzeModule
};Provides high-performance lexical analysis of CommonJS modules to extract export information.