or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@babel/runtime@7.28.x
tile.json

tessl/npm-babel--runtime

tessl install tessl/npm-babel--runtime@7.28.0

Babel's modular runtime helpers that provide transpilation support for modern JavaScript features

Agent Success

Agent success rate when using this tile

94%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.19x

Baseline

Agent success rate without this tile

79%

task.mdevals/scenario-9/

AST Transformation with Safe Cloning

Build a JavaScript code transformation utility that safely transforms code while preserving the original Abstract Syntax Tree (AST) for comparison purposes.

Requirements

Create a module that exports a function transformWithComparison that:

  1. Accepts JavaScript source code as a string
  2. Transforms all var declarations to const declarations
  3. Returns an object containing:
    • original: The original, unmodified AST (must remain unchanged even after transformation)
    • transformed: The transformed JavaScript code as a string
    • wasModified: A boolean indicating whether any var-to-const transformations occurred

The original AST must remain completely unmodified after the transformation completes, preserving its initial state for comparison purposes.

@generates

API

/**
 * Transforms JavaScript code while preserving the original AST.
 *
 * @param {string} sourceCode - The JavaScript source code to transform
 * @returns {Object} An object with original AST, transformed code, and modification status
 * @returns {Object} returns.original - The original, unmodified AST
 * @returns {string} returns.transformed - The transformed JavaScript code
 * @returns {boolean} returns.wasModified - Whether any transformations were applied
 */
function transformWithComparison(sourceCode) {
  // Implementation
}

module.exports = { transformWithComparison };

Test Cases

  • Given code var x = 1;, the function returns an object where transformed is const x = 1;, wasModified is true, and original is an unmodified AST @test
  • Given code const y = 2; (already using const), the function returns wasModified as false and transformed equals the input @test
  • After transformation, the original AST's VariableDeclaration nodes still have kind "var" (not mutated) @test

Dependencies { .dependencies }

@babel/core { .dependency }

Provides JavaScript transformation and parsing capabilities with AST cloning support.

@satisfied-by