CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-swc--core-darwin-arm64

Platform-specific native binary for SWC TypeScript/JavaScript compiler on macOS ARM64 architecture

89

1.15x
Overview
Eval results
Files

task.mdevals/scenario-5/

JavaScript Minifier with Constant Folding

A code minification utility that performs constant folding and expression simplification on JavaScript code.

Capabilities

Basic Constant Folding

Evaluate compile-time constant expressions and replace them with their computed values.

  • Given code const x = 2 + 3;, the minifier produces const x=5; @test
  • Given code const result = 10 * 5 - 20;, the minifier produces const result=30; @test
  • Given code const flag = true && false;, the minifier produces const flag=false; @test

String Expression Simplification

Simplify string concatenation expressions at compile time.

  • Given code const greeting = "Hello" + " " + "World";, the minifier produces const greeting="Hello World"; @test
  • Given code const path = "src" + "/" + "index.js";, the minifier produces const path="src/index.js"; @test

Comparison Expression Simplification

Evaluate and simplify comparison expressions with constant operands.

  • Given code const check = 5 > 3;, the minifier produces const check=true; @test
  • Given code const equal = 10 === 10;, the minifier produces const equal=true; @test

Conditional Expression Simplification

Simplify ternary and conditional expressions when the condition is constant.

  • Given code const value = true ? 42 : 0;, the minifier produces const value=42; @test
  • Given code const value = false ? 42 : 0;, the minifier produces const value=0; @test

Implementation

@generates

API

/**
 * Minifies JavaScript code with constant folding and expression simplification.
 *
 * @param {string} code - The JavaScript source code to minify.
 * @param {Object} options - Optional configuration for minification.
 * @param {boolean} options.compress - Enable compression optimizations (default: true).
 * @returns {Promise<{code: string}>} A promise that resolves to an object containing the minified code.
 * @throws {Error} Throws an error if the code cannot be parsed or minified.
 */
async function minify(code, options = {}) {
  // IMPLEMENTATION HERE
}

module.exports = { minify };

Dependencies { .dependencies }

@swc/core { .dependency }

Provides high-performance JavaScript/TypeScript compilation, minification, and optimization capabilities including constant folding and expression simplification.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-swc--core-darwin-arm64

tile.json