Giter Site home page Giter Site logo

codetransformer's Introduction

Code Transformer

"Code Transformer" is a Visual Studio Code extension that allows you to transform or process code by executing custom JavaScript expressions or preset expressions.

Features

Basic Usage

No configuration is required. Simply use the transform code extension command to manually input an expression.

Parameters

The parameters that can be used in the expression are:

  • s: Current line of text
  • l: Current line number
  • f: Built-in function object

Example: Reverse the current line of text

  1. Select the line of text you want to process.
  2. Open the command palette and execute the transform code extension command.
  3. In the input box that appears, type s.split('').reverse().join('').
  4. After execution, the selected line of text will be reversed.

Advanced Usage

1. Using Built-in Functions

You can configure built-in functions in the settings panel to call these functions in expressions.

Example: Configure a built-in function to transform text to snake_case
  1. Open settings and navigate to the Code Transformer settings.
  2. In the "Built-in Functions" section, add a new function, for example:
[
    {
        "name": "toSnakeCase",
        "code": "(str) => { return str.replace(/([A-Z])/g, '_$1').toLowerCase(); }"
    }
]
  1. Save the settings.
  2. Now you can use f.toSnakeCase(s) in the input box for the transform code extension command or in preset expressions.

2. Using Preset Expressions

You can configure preset expressions in the settings panel for quick selection and execution.

Example: Configure a preset expression
  1. Open settings and navigate to the Code Transformer settings.
  2. In the "Preset Expressions" section, add a new expression, for example:
[
    {
        "name": "toSnakeCaseExp",
        "code": "f.toSnakeCase(s)"
    }
]
  1. Save the settings.
  2. Now you can open the list of preset expressions (quickPick) via the transform pick extension command and choose this preset expression for execution.

Support

Licensed under the MIT License.

For any questions or suggestions, please contact us.

codetransformer's People

Watchers

jindong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.