or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

array-iteration-helpers.mdasync-generator-helpers.mdclass-object-helpers.mdcore-helper-management.mdindex.mdmodule-import-helpers.mdutility-runtime-helpers.md
tile.json

tessl/npm-babel--helpers

Collection of helper functions used by Babel transforms for generating runtime code.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@babel/helpers@7.28.x

To install, run

npx @tessl/cli install tessl/npm-babel--helpers@7.28.0

index.mddocs/

@babel/helpers

@babel/helpers is a comprehensive collection of helper functions used internally by Babel transforms to generate runtime code for various JavaScript features. It provides utilities for managing helper function dependencies, versioning, and APIs to retrieve, build, and inject helper code into transformed JavaScript output.

Package Information

  • Package Name: @babel/helpers
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @babel/helpers

Core Imports

import { get, minVersion, getDependencies, isInternal, list } from "@babel/helpers";

For CommonJS:

const { get, minVersion, getDependencies, isInternal, list } = require("@babel/helpers");

Default import (alias for get function):

import helpers from "@babel/helpers";

Basic Usage

import { get, list, getDependencies } from "@babel/helpers";

// Get list of all available helpers
const availableHelpers = list;
console.log(availableHelpers); // ['asyncToGenerator', 'classCallCheck', ...]

// Get helper AST for a specific helper
const helperAST = get("asyncToGenerator");
console.log(helperAST.nodes); // Array of AST nodes
console.log(helperAST.globals); // Array of global variables used

// Check helper dependencies
const deps = getDependencies("asyncToGenerator");
console.log(deps); // Array of dependency helper names

// Check minimum Babel version required
const minVer = minVersion("asyncToGenerator");
console.log(minVer); // "7.0.0-beta.0"

Architecture

@babel/helpers is built around several key components:

  • Helper Registry: Central repository of all available helper functions stored as AST templates
  • Dependency Resolution: System for managing helper interdependencies and transitive dependencies
  • AST Permutation: Engine for customizing helper ASTs based on usage context (binding names, local variables)
  • Version Management: Tracking minimum Babel versions required for each helper
  • Code Generation: Utilities for building helper code with proper scoping and conflict avoidance

Capabilities

Core Helper Management

Primary API for retrieving and building helper ASTs with customization options. Essential for Babel plugins that need to inject runtime helpers.

function get(
  name: string,
  getDependency?: GetDependency,
  bindingName?: string,
  localBindings?: string[],
  adjustAst?: AdjustAst
): { nodes: t.Program["body"]; globals: string[] };

function minVersion(name: string): string;

function getDependencies(name: string): ReadonlyArray<string>;

function isInternal(name: string): boolean;

function ensure(name: string): void; // CommonJS only

const list: string[];

Core Helper Management

Array and Iteration Helpers

Comprehensive collection of helpers for array operations, destructuring, and iteration patterns including for-of loops, spread syntax, and rest parameters.

// Key helpers for array operations
const arrayHelpers = [
  "arrayLikeToArray", "arrayWithHoles", "arrayWithoutHoles",
  "createForOfIteratorHelper", "createForOfIteratorHelperLoose",
  "iterableToArray", "iterableToArrayLimit", "maybeArrayLike",
  "nonIterableRest", "nonIterableSpread", "slicedToArray",
  "toArray", "toConsumableArray", "unsupportedIterableToArray"
];

Array and Iteration Helpers

Class and Object Helpers

Extensive set of helpers for class syntax, inheritance, private fields, decorators, and object operations including property access and manipulation.

// Key helpers for class and object operations
const classObjectHelpers = [
  "assertClassBrand", "assertThisInitialized", "classCallCheck", 
  "classPrivateFieldGet2", "classPrivateFieldSet2", "createClass",
  "extends", "inherits", "construct", "defineProperty", "get", "set"
];

Class and Object Helpers

Async and Generator Helpers

Helper functions for async/await syntax, generator functions, and async iteration patterns including regenerator runtime integration.

// Key helpers for async and generator operations  
const asyncGeneratorHelpers = [
  "asyncToGenerator", "asyncGeneratorDelegate", "asyncIterator",
  "awaitAsyncGenerator", "wrapAsyncGenerator", "regenerator",  
  "regeneratorAsync", "regeneratorAsyncGen", "skipFirstGeneratorNext"
];

Async and Generator Helpers

Module and Import Helpers

Utilities for handling module interoperability, import/export patterns, and CommonJS/ES Module compatibility.

// Key helpers for module operations
const moduleHelpers = [
  "interopRequireDefault", "interopRequireWildcard", 
  "importDeferProxy", "tsRewriteRelativeImportExtensions"
];

Module and Import Helpers

Utility and Runtime Helpers

Collection of utility functions for type checking, error handling, JSX, template literals, and other runtime operations.

// Key utility helpers
const utilityHelpers = [
  "typeof", "instanceof", "jsx", "taggedTemplateLiteral",
  "nullishReceiverError", "readOnlyError", "writeOnlyError",
  "temporalUndefined", "tdz", "identity", "usingCtx"
];

Utility and Runtime Helpers

Types

type GetDependency = (name: string) => t.Expression;

type AdjustAst = (
  ast: t.Program,
  exportName: string,
  mapExportBindingAssignments: (
    map: (node: t.Expression) => t.Expression,
  ) => void,
) => void;

interface HelperMetadata {
  globals: string[];
  locals: { [name: string]: string[] };
  dependencies: { [name: string]: string[] };
  exportBindingAssignments: string[];
  exportName: string;
  internal: boolean;
}