CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-istanbul-lib-source-maps

Source maps support for Istanbul code coverage toolkit, enabling accurate coverage reporting for transpiled JavaScript code

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-9/

Source Map Retrieval Tool

Build a tool that manages and retrieves source maps for transpiled JavaScript files.

Overview

Your tool should register source maps for transpiled files and provide synchronous retrieval of those source maps. The tool needs to support different source map formats and generate simple reports about source map availability.

Requirements

Registration

Register source maps in two ways:

  • Register a source map by providing a file path and a URL/path to the source map file
  • Register a source map by providing a file path and a parsed source map object

Retrieval

Retrieve registered source maps synchronously:

  • Given a file path, return the associated source map object if one was registered
  • Return undefined if no source map exists for the given file path

Reporting

Generate a simple availability report:

  • Accept a list of file paths
  • Return which files have source maps registered and which do not

Test Cases

  • Registering a source map via URL for "build/app.js" and then retrieving it returns the source map object. @test
  • Registering a source map object for "dist/main.js" and then retrieving it returns that object. @test
  • Retrieving a source map for "output.js" that was never registered returns undefined. @test
  • Generating a report for files ["file1.js", "file2.js"] where only file1.js has a registered source map correctly shows file1.js as available and file2.js as missing. @test

Implementation

@generates

API

/**
 * Retrieves source map information for registered files
 * @param {string} filePath - Path to the file
 * @returns {Object|undefined} Source map object or undefined if not found
 */
function getSourceMap(filePath);

/**
 * Registers a source map URL for a file
 * @param {string} filePath - Path to the transpiled file
 * @param {string} sourceMapUrl - URL or path to the source map
 */
function registerSourceMapURL(filePath, sourceMapUrl);

/**
 * Registers a source map object for a file
 * @param {string} filePath - Path to the transpiled file
 * @param {Object} sourceMapObject - Parsed source map object
 */
function registerSourceMapObject(filePath, sourceMapObject);

/**
 * Generates a report of source map availability
 * @param {string[]} filePaths - Array of file paths to check
 * @returns {Object} Report object with 'available' and 'missing' arrays
 */
function generateReport(filePaths);

Dependencies { .dependencies }

istanbul-lib-source-maps { .dependency }

Provides source map storage, registration, and retrieval capabilities for coverage transformation workflows.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-istanbul-lib-source-maps

tile.json