CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel--plugin-proposal-object-rest-spread

Babel plugin that transforms ECMAScript object rest and spread syntax into ES5-compatible code.

85

1.06x

Quality

Pending

Does it follow best practices?

Impact

85%

1.06x

Average score across 10 eval scenarios

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

task.mdevals/scenario-6/

AST Function Builder

A utility that programmatically constructs JavaScript function declarations as Abstract Syntax Trees (AST).

Capabilities

Create function declaration nodes

Build a complete function declaration AST node with a given name, parameters, and body statements.

  • Given name "add", parameters ["a", "b"], and a return statement for "a + b", creates a valid function declaration AST node @test
  • Given name "greet", parameters ["name"], and a return statement for a template literal, creates a valid function declaration AST node @test

Validate AST node types

Check if created nodes are of the correct AST node type.

  • A created function declaration node passes type validation for function declarations @test
  • A created identifier node passes type validation for identifiers @test

Clone AST nodes

Create deep copies of AST nodes while preserving structure.

  • Cloning a function declaration creates an independent copy that can be modified without affecting the original @test

Implementation

@generates

API

/**
 * Creates a function declaration AST node.
 *
 * @param {string} functionName - The name of the function.
 * @param {string[]} parameterNames - Array of parameter names.
 * @param {Object} bodyExpression - An AST node representing the expression to return.
 * @returns {Object} A function declaration AST node.
 */
function createFunctionDeclaration(functionName, parameterNames, bodyExpression) {
  // IMPLEMENTATION HERE
}

/**
 * Validates if a given AST node is of a specific type.
 *
 * @param {Object} node - The AST node to validate.
 * @param {string} typeName - The expected node type (e.g., "FunctionDeclaration", "Identifier").
 * @returns {boolean} True if the node matches the type, false otherwise.
 */
function isNodeType(node, typeName) {
  // IMPLEMENTATION HERE
}

/**
 * Creates a deep clone of an AST node.
 *
 * @param {Object} node - The AST node to clone.
 * @returns {Object} A deep copy of the node.
 */
function cloneNode(node) {
  // IMPLEMENTATION HERE
}

module.exports = {
  createFunctionDeclaration,
  isNodeType,
  cloneNode,
};

Dependencies { .dependencies }

@babel/types { .dependency }

Provides utilities for AST node creation, validation, and manipulation.

@satisfied-by

tile.json