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

type-system.mddocs/

Type System Helpers

Utilities for type checking, conversion, and property access operations commonly used in TypeScript and JavaScript.

Capabilities

Type Checking

_type_of

Enhanced typeof operator with proper null handling.

/**
 * Enhanced typeof operator with proper null handling
 * @param {any} obj - Value to check type of
 * @returns {string} Type string ("object", "function", "undefined", etc.)
 */
function _type_of(obj): string;

Usage Example:

_type_of(null); // "object" (matches JS behavior)
_type_of([]); // "object"
_type_of(() => {}); // "function"

_instanceof

Enhanced instanceof operator with proper handling.

/**
 * Enhanced instanceof operator with proper handling
 * @param {any} left - Value to check
 * @param {Function} right - Constructor to check against
 * @returns {boolean} True if left is instance of right
 */
function _instanceof(left, right): boolean;

Type Conversion

_to_primitive

Converts values to primitive types.

/**
 * Converts values to primitive types
 * @param {any} input - Value to convert
 * @param {string} hint - Conversion hint ("string", "number", "default")
 * @returns {any} Primitive value
 */
function _to_primitive(input, hint): any;

_to_property_key

Converts values to property keys.

/**
 * Converts values to property keys
 * @param {any} arg - Value to convert to property key
 * @returns {string|symbol} Property key
 */
function _to_property_key(arg): string | symbol;

Property Operations

_define_property

Defines properties on objects with proper fallbacks.

/**
 * Defines properties on objects with proper fallbacks
 * @param {Object} obj - Target object
 * @param {string|symbol} key - Property key
 * @param {any} value - Property value
 * @returns {Object} Target object
 */
function _define_property(obj, key, value): Object;

_define_enumerable_properties

Defines multiple enumerable properties.

/**
 * Defines multiple enumerable properties
 * @param {Object} target - Target object
 * @param {Object} props - Properties to define
 * @returns {Object} Target object
 */
function _define_enumerable_properties(target, props): Object;

Prototype Operations

_get_prototype_of

Gets the prototype of an object.

/**
 * Gets the prototype of an object
 * @param {Object} o - Object to get prototype of
 * @returns {Object|null} Prototype object or null
 */
function _get_prototype_of(o): Object | null;

_set_prototype_of

Sets the prototype of an object.

/**
 * Sets the prototype of an object
 * @param {Object} o - Object to set prototype on
 * @param {Object|null} p - New prototype
 * @returns {Object} Target object
 */
function _set_prototype_of(o, p): Object;

Tagged Templates

_tagged_template_literal

Handles tagged template literal objects.

/**
 * Handles tagged template literal objects
 * @param {Array} strings - Template strings array
 * @param {Array} raw - Raw strings array
 * @returns {Array} Template object with raw property
 */
function _tagged_template_literal(strings, raw): Array;

_tagged_template_literal_loose

Loose mode tagged template literal handling.

/**
 * Loose mode tagged template literal handling
 * @param {Array} strings - Template strings array
 * @param {Array} raw - Raw strings array
 * @returns {Array} Template object
 */
function _tagged_template_literal_loose(strings, raw): Array;

Arrow Function Helpers

_new_arrow_check

Prevents arrow functions from being called with new.

/**
 * Prevents arrow functions from being called with new
 * @param {any} innerThis - Arrow function this context
 * @param {any} boundThis - Bound this context
 * @throws {TypeError} If arrow function called with new
 */
function _new_arrow_check(innerThis, boundThis): void;

Identity Function

_identity

Simple identity function that returns its argument.

/**
 * Simple identity function that returns its argument
 * @param {any} x - Value to return
 * @returns {any} The input value unchanged
 */
function _identity(x): any;

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