Babel's modular runtime helpers that provide transpilation support for modern JavaScript features
npx @tessl/cli install tessl/npm-babel--runtime@7.28.0@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.
npm install @babel/runtimeIndividual 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');// 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);@babel/runtime is organized around modular helper functions that implement transpilation patterns:
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[];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;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;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>;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;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;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;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;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;// 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;
}