or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-6/

Multi-File Encoding Analyzer

Build a utility that analyzes the character encodings of multiple text files concurrently and generates a summary report.

Requirements

Create a module that processes a list of file paths and determines their character encodings. The module should:

  1. Accept an array of file paths as input
  2. Analyze all files concurrently to determine their character encodings
  3. Return a summary object containing:
    • A map of file paths to their detected encodings
    • A count of files by encoding type
    • A list of any files that could not be analyzed

For performance reasons, when analyzing large files (over 100KB), only sample the first 32KB of data.

Test Cases

  • Given an array of file paths, it returns a results object with encoding information for each file @test
  • When analyzing large files, it samples only the first 32KB for performance @test
  • It processes all files concurrently and completes in reasonable time @test

Implementation

@generates

API

/**
 * Analyzes the character encodings of multiple files concurrently.
 *
 * @param {string[]} filePaths - Array of file paths to analyze
 * @returns {Promise<AnalysisResult>} Analysis results
 */
async function analyzeEncodings(filePaths) {
  // IMPLEMENTATION HERE
}

/**
 * @typedef {Object} AnalysisResult
 * @property {Object.<string, string|null>} encodings - Map of file paths to detected encodings
 * @property {Object.<string, number>} summary - Count of files by encoding type
 * @property {string[]} failed - List of file paths that could not be analyzed
 */

module.exports = {
  analyzeEncodings
};

Dependencies { .dependencies }

chardet { .dependency }

Provides character encoding detection functionality.