CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-babel--helper-get-function-arity

Helper function to get function arity by analyzing parameter lists for assignment patterns and rest parameters

95

1.06x
Overview
Eval results
Files

task.mdevals/scenario-10/

Function Arity Analyzer Plugin

A Babel plugin that analyzes function declarations and adds comments indicating the number of required parameters.

Capabilities

Analyze function arity

The plugin should traverse all function nodes and determine their arity (number of required parameters), adding a leading comment to each function.

  • Given function foo() {}, the plugin adds the comment /* Required params: 0 */ before the function @test
  • Given function bar(a, b, c) {}, the plugin adds the comment /* Required params: 3 */ before the function @test
  • Given function baz(a, b = 10) {}, the plugin adds the comment /* Required params: 1 */ before the function @test
  • Given function qux(a, b, ...rest) {}, the plugin adds the comment /* Required params: 2 */ before the function @test

Implementation

@generates

API

/**
 * Babel plugin that adds leading comments to functions indicating their required parameter count.
 *
 * @returns {Object} A Babel plugin object with a visitor
 */
module.exports = function arityAnalyzerPlugin() {
  // Plugin implementation
};

Dependencies { .dependencies }

@babel/helper-get-function-arity { .dependency }

Provides function arity calculation support.

@satisfied-by

@babel/core { .dependency }

Provides Babel transformation support.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-babel--helper-get-function-arity

tile.json