or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

array-helpers.mdasync-generators.mdclass-helpers.mddecorators.mdindex.mdmodule-interop.mdobject-helpers.mdprivate-members.mdresource-management.mdtype-utilities.md
tile.json

tessl/npm-babel--runtime

Babel's modular runtime helpers that provide transpilation support for modern JavaScript features

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

To install, run

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

index.mddocs/

@babel/runtime

@babel/runtime is Babel's modular runtime helpers library that provides essential transpilation support for modern JavaScript features. It contains 122 individual helper functions that are automatically injected by Babel plugins to avoid code duplication across transpiled modules. The package supports both CommonJS and ESM imports and includes comprehensive generator/async function support through regenerator runtime.

Package Information

  • Package Name: @babel/runtime
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install @babel/runtime

Core Imports

Individual helpers (ESM):

import _extends from '@babel/runtime/helpers/esm/extends';
import _asyncToGenerator from '@babel/runtime/helpers/esm/asyncToGenerator';
import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';

Individual helpers (CommonJS):

const _extends = require('@babel/runtime/helpers/extends');
const _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
const _classCallCheck = require('@babel/runtime/helpers/classCallCheck');

Regenerator runtime:

import '@babel/runtime/regenerator';
// or
require('@babel/runtime/regenerator');

Basic Usage

// Object extension
import _extends from '@babel/runtime/helpers/esm/extends';

const config = _extends({}, defaultConfig, userConfig);

// Async function support
import _asyncToGenerator from '@babel/runtime/helpers/esm/asyncToGenerator';
import '@babel/runtime/regenerator';

const asyncFn = _asyncToGenerator(function* () {
  return yield Promise.resolve('hello');
});

// Class inheritance
import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
import _createClass from '@babel/runtime/helpers/esm/createClass';
import _inherits from '@babel/runtime/helpers/esm/inherits';
import _createSuper from '@babel/runtime/helpers/esm/createSuper';

function Child() {
  _classCallCheck(this, Child);
  return _createSuper(Child).call(this);
}

_inherits(Child, Parent);

Architecture

@babel/runtime is organized around modular helper functions that implement transpilation patterns:

  • Helper Functions: Individual utilities for specific JavaScript language features (classes, async/await, destructuring, etc.)
  • Dual Module Support: Both CommonJS and ESM versions available for optimal compatibility
  • Tree-shakable: Each helper is a separate module allowing bundlers to include only what's needed
  • Regenerator Integration: Complete runtime support for generators and async functions
  • Polyfill Patterns: Helpers include fallbacks for older JavaScript environments

Capabilities

Array and Iterable Operations

Utilities for array conversion, iteration, and destructuring operations that handle edge cases and provide consistent behavior across environments.

function arrayLikeToArray<T>(arr: ArrayLike<T>, len?: number | null): T[];
function toConsumableArray<T>(arr: any): T[];
function slicedToArray<T>(arr: any, i: number): T[];

Array and Iterable Helpers

Class and Inheritance System

Comprehensive class system support including constructor validation, inheritance chains, super calls, and property access patterns.

function classCallCheck<T extends object>(
  instance: unknown, 
  Constructor: new (...args: any[]) => T
): asserts instance is T;
function createClass(
  Constructor: Function, 
  protoProps?: PropertyDescriptor[], 
  staticProps?: PropertyDescriptor[]
): Function;
function inherits(subClass: Function, superClass: Function): void;
function createSuper(Derived: Function): Function;

Class and Inheritance Helpers

Private Fields and Methods

Modern JavaScript private member access including private fields, methods, static members, and brand checking.

function classPrivateFieldGet(receiver: any, privateMap: WeakMap<any, any>): any;
function classPrivateFieldSet(receiver: any, privateMap: WeakMap<any, any>, value: any): any;
function classPrivateMethodGet(receiver: any, privateSet: WeakSet<any>, fn: Function): Function;
function assertClassBrand(e: any, t: any, n?: any): any;

Private Member Helpers

Async and Generator Support

Complete async/await and generator function support including regenerator runtime, async iterators, and generator delegation.

function asyncToGenerator<This, Args extends unknown[], TYield, TReturn>(
  fn: (this: This, ...args: Args) => Generator<TYield, TReturn, Awaited<TYield>>
): (this: This, ...args: Args) => Promise<TReturn>;
function wrapAsyncGenerator(fn: Function): Function;
function asyncGeneratorDelegate(inner: AsyncIterator<any>, awaitWrap: Function): AsyncIterator<any>;

Async and Generator Helpers

Object Manipulation

Object extension, property management, and destructuring operations with cross-environment compatibility.

function _extends<T extends object, U extends unknown[]>(
  target: T, 
  ...sources: U
): T & Intersection<U>;
function objectSpread2(target: any, ...sources: any[]): any;
function objectWithoutProperties(obj: any, keys: string[]): any;
function defineProperty(obj: any, key: PropertyKey, descriptor: PropertyDescriptor): any;

Object Manipulation Helpers

Type System and Utilities

Type checking, control flow validation, error generation, and utility functions for robust transpiled code.

function _typeof(obj: any): string;
function _instanceof(left: any, right: any): boolean;
function readOnlyError(name: string): never;
function temporalUndefined(): any;

Type and Utility Helpers

Decorator Support

Full decorator implementation supporting multiple decorator proposal stages from legacy to current specifications.

function applyDecs2311(
  targetClass: Function,
  memberDecs: any[][],
  classDecs: any[],
  classDecsHaveThis: boolean,
  instanceBrand: Function
): [Function, Function[], Function[]];
function applyDecoratedDescriptor(
  target: any,
  property: PropertyKey,
  decorators: Function[],
  descriptor: PropertyDescriptor,
  context: any
): PropertyDescriptor;

Decorator Helpers

Module Interoperability

Import/export compatibility helpers for seamless interaction between CommonJS and ESM modules.

function interopRequireDefault(obj: any): { default: any } | any;
function interopRequireWildcard(obj: any): any;
function importDeferProxy(init: Function): any;

Module Interop Helpers

Resource Management

Modern JavaScript resource management and disposal patterns for using/disposable resources and explicit resource cleanup.

function using(stack: any[], value: any, async?: boolean): any;
function dispose(SuppressedError: any, stack: any[], async?: boolean): any;
function usingCtx(value: any): any;

Resource Management Helpers

Types

// Core types used across helpers
type PropertyKey = string | number | symbol;
type ArrayLike<T> = { length: number; [key: number]: T };
type GeneratorFunction = () => Generator<any, any, any>;

// Helper utility types
type Intersection<R extends any[]> = R extends [infer H, ...infer S]
  ? H & Intersection<S>
  : unknown;

// Class-related types
interface ClassConstructor extends Function {
  prototype: any;
}

// Descriptor types
interface PropertyDescriptor {
  configurable?: boolean;
  enumerable?: boolean;
  value?: any;
  writable?: boolean;
  get?(): any;
  set?(value: any): void;
}

// Async generator types  
interface AsyncIterator<T> {
  next(value?: any): Promise<IteratorResult<T>>;
  return?(value?: any): Promise<IteratorResult<T>>;
  throw?(e?: any): Promise<IteratorResult<T>>;
}

interface IteratorResult<T> {
  done: boolean;
  value: T;
}