CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel-plugin-transform-es2015-literals

Babel plugin that compiles ES2015 unicode string and number literals to ES5

86

0.97x
Overview
Eval results
Files

task.mdevals/scenario-3/

Binary Code Transformer

A code transformation utility that converts JavaScript source code containing binary literals to ES5-compatible code with decimal numbers.

Capabilities

Transform binary literals in code

  • Given code "const timeout = 0b1111101000;", the transformer returns "const timeout = 1000;" @test
  • Given code "const flags = 0B101;", the transformer returns "const flags = 5;" @test
  • Given code with multiple binary literals "const port = 0b10000000000; const buffer = 0b100000000;", the transformer converts all binary values to decimal @test

Handle various code patterns

  • Given code "const value = 0b1111.toString();", the transformer correctly handles method calls on binary literals @test

Implementation

@generates

API

/**
 * Transforms JavaScript code containing binary literals to ES5-compatible code.
 *
 * @param {string} code - The JavaScript source code to transform
 * @returns {string} The transformed code with binary literals converted to decimal
 */
function transformCode(code) {
  // IMPLEMENTATION HERE
}

module.exports = { transformCode };

Dependencies { .dependencies }

@babel/core { .dependency }

Provides the Babel transformation engine.

@satisfied-by

@babel/plugin-transform-literals { .dependency }

Provides binary literal transformation from 0b/0B prefix format to decimal.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-babel-plugin-transform-es2015-literals

tile.json