CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-swc--helpers

Runtime helper functions for JavaScript and TypeScript transformations performed by the SWC compiler.

Pending
Overview
Eval results
Files

destructuring.mddocs/

Destructuring Helpers

Support for destructuring assignments, rest/spread operators, and array/object manipulation patterns.

Capabilities

Array Destructuring

_sliced_to_array

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);

_sliced_to_array_loose

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;

_to_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;

_array_with_holes

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;

_array_without_holes

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;

_array_like_to_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;

Iterable Helpers

_iterable_to_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;

_iterable_to_array_limit

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;

_iterable_to_array_limit_loose

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;

_unsupported_iterable_to_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;

Spread Operators

_to_consumable_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;

_non_iterable_spread

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;

_non_iterable_rest

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;

Object Destructuring

_object_without_properties

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"]);

_object_without_properties_loose

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;

_object_destructuring_empty

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;

Object Spread

_object_spread

Handles object spread operations.

/**
 * Handles object spread operations
 * @param {...Object} sources - Source objects to spread
 * @returns {Object} Merged object
 */
function _object_spread(...sources): Object;

_object_spread_props

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;

General Object Utilities

_extends

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;

_defaults

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

docs

async-generators.md

class-system.md

decorators.md

destructuring.md

index.md

module-interop.md

private-fields.md

type-system.md

utilities.md

tile.json