Runtime helper functions for JavaScript and TypeScript transformations performed by the SWC compiler.
—
Support for destructuring assignments, rest/spread operators, and array/object manipulation patterns.
Converts arrays to fixed-length arrays for destructuring.
/**
* Converts arrays to fixed-length arrays for destructuring
* @param {Array} arr - Source array
* @param {number} i - Maximum number of elements
* @returns {Array} Fixed-length array
*/
function _sliced_to_array(arr, i): Array;Usage Example:
// For: const [a, b] = someArray;
const [a, b] = _sliced_to_array(someArray, 2);Loose mode array slicing for destructuring.
/**
* Loose mode array slicing for destructuring
* @param {Array} arr - Source array
* @param {number} i - Maximum number of elements
* @returns {Array} Sliced array
*/
function _sliced_to_array_loose(arr, i): Array;Converts iterables to arrays for destructuring.
/**
* Converts iterables to arrays for destructuring
* @param {Iterable} arr - Iterable to convert
* @returns {Array} Converted array
*/
function _to_array(arr): Array;Handles arrays with holes in destructuring.
/**
* Handles arrays with holes in destructuring
* @param {Array} arr - Array with potential holes
* @returns {Array} Array with holes preserved
*/
function _array_with_holes(arr): Array;Converts arrays to dense arrays (removes holes).
/**
* Converts arrays to dense arrays (removes holes)
* @param {Array} arr - Array with potential holes
* @returns {Array} Dense array
*/
function _array_without_holes(arr): Array;Converts array-like objects to arrays.
/**
* Converts array-like objects to arrays
* @param {ArrayLike} o - Array-like object
* @param {number} minLen - Minimum length
* @returns {Array} Converted array
*/
function _array_like_to_array(o, minLen): Array;Converts iterables to arrays.
/**
* Converts iterables to arrays
* @param {Iterable} iter - Iterable to convert
* @returns {Array} Converted array
*/
function _iterable_to_array(iter): Array;Converts iterables to arrays with length limit.
/**
* Converts iterables to arrays with length limit
* @param {Iterable} arr - Iterable to convert
* @param {number} i - Maximum length
* @returns {Array} Limited array
*/
function _iterable_to_array_limit(arr, i): Array;Loose mode iterable to array conversion with limit.
/**
* Loose mode iterable to array conversion with limit
* @param {Iterable} arr - Iterable to convert
* @param {number} i - Maximum length
* @returns {Array} Limited array
*/
function _iterable_to_array_limit_loose(arr, i): Array;Handles unsupported iterables with fallbacks.
/**
* Handles unsupported iterables with fallbacks
* @param {any} o - Object to convert
* @param {number} minLen - Minimum length
* @returns {Array} Converted array
* @throws {TypeError} If conversion not possible
*/
function _unsupported_iterable_to_array(o, minLen): Array;Converts iterables to consumable arrays for spread operations.
/**
* Converts iterables to consumable arrays for spread operations
* @param {Iterable} arr - Iterable to convert
* @returns {Array} Consumable array
*/
function _to_consumable_array(arr): Array;Handles non-iterable values in spread operations.
/**
* Handles non-iterable values in spread operations
* @throws {TypeError} Non-iterable spread error
*/
function _non_iterable_spread(): never;Handles non-iterable values in rest patterns.
/**
* Handles non-iterable values in rest patterns
* @throws {TypeError} Non-iterable rest error
*/
function _non_iterable_rest(): never;Removes specified properties from objects.
/**
* Removes specified properties from objects
* @param {Object} source - Source object
* @param {Array} excluded - Properties to exclude
* @returns {Object} Object without excluded properties
*/
function _object_without_properties(source, excluded): Object;Usage Example:
// For: const {a, ...rest} = obj;
const rest = _object_without_properties(obj, ["a"]);Loose mode object property exclusion.
/**
* Loose mode object property exclusion
* @param {Object} source - Source object
* @param {Array} excluded - Properties to exclude
* @returns {Object} Object without excluded properties
*/
function _object_without_properties_loose(source, excluded): Object;Handles empty object destructuring patterns.
/**
* Handles empty object destructuring patterns
* @param {any} obj - Object to check
* @throws {TypeError} If obj is null or undefined
*/
function _object_destructuring_empty(obj): void;Handles object spread operations.
/**
* Handles object spread operations
* @param {...Object} sources - Source objects to spread
* @returns {Object} Merged object
*/
function _object_spread(...sources): Object;Handles object spread with specific properties.
/**
* Handles object spread with specific properties
* @param {Object} target - Target object
* @param {Array} sources - Source objects and properties
* @returns {Object} Object with spread properties
*/
function _object_spread_props(target, sources): Object;Extends objects (similar to Object.assign).
/**
* Extends objects (similar to Object.assign)
* @param {Object} target - Target object
* @param {...Object} sources - Source objects
* @returns {Object} Extended object
*/
function _extends(target, ...sources): Object;Sets default property values on objects.
/**
* Sets default property values on objects
* @param {Object} obj - Target object
* @param {...Object} defaults - Default value objects
* @returns {Object} Object with defaults applied
*/
function _defaults(obj, ...defaults): Object;Install with Tessl CLI
npx tessl i tessl/npm-swc--helpers