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

private-fields.mddocs/

Private Field Helpers

Runtime implementation of private class fields and methods, providing encapsulation features for classes.

Capabilities

Private Instance Fields

_class_private_field_get

Gets the value of a private instance field.

/**
 * Gets the value of a private instance field
 * @param {Object} receiver - The instance containing the private field
 * @param {WeakMap} privateMap - WeakMap storing private field values
 * @returns {any} The private field value
 * @throws {TypeError} If private field not found
 */
function _class_private_field_get(receiver, privateMap): any;

Usage Example:

// For a private field #value
const privateValue = _class_private_field_get(this, _value);

_class_private_field_set

Sets the value of a private instance field.

/**
 * Sets the value of a private instance field
 * @param {Object} receiver - The instance containing the private field
 * @param {WeakMap} privateMap - WeakMap storing private field values
 * @param {any} value - Value to set
 * @returns {any} The set value
 */
function _class_private_field_set(receiver, privateMap, value): any;

_class_private_field_init

Initializes a private instance field.

/**
 * Initializes a private instance field
 * @param {Object} obj - The instance to initialize
 * @param {WeakMap} privateMap - WeakMap to store the private field
 * @param {any} value - Initial value
 */
function _class_private_field_init(obj, privateMap, value): void;

_class_private_field_update

Updates a private instance field with an operation.

/**
 * Updates a private instance field with an operation
 * @param {Object} receiver - The instance containing the private field
 * @param {WeakMap} privateMap - WeakMap storing private field values
 * @param {Function} updateFn - Update function
 * @returns {any} The updated value
 */
function _class_private_field_update(receiver, privateMap, updateFn): any;

_class_private_field_destructure

Handles destructuring of private fields.

/**
 * Handles destructuring of private fields
 * @param {Object} receiver - The instance containing the private field
 * @param {WeakMap} privateMap - WeakMap storing private field values
 * @returns {any} The private field value for destructuring
 */
function _class_private_field_destructure(receiver, privateMap): any;

Private Instance Methods

_class_private_method_get

Gets a private instance method.

/**
 * Gets a private instance method
 * @param {Object} receiver - The instance containing the private method
 * @param {WeakSet} privateSet - WeakSet tracking private method access
 * @param {Function} fn - The private method function
 * @returns {Function} The private method bound to receiver
 */
function _class_private_method_get(receiver, privateSet, fn): Function;

_class_private_method_init

Initializes a private instance method.

/**
 * Initializes a private instance method
 * @param {Object} obj - The instance to initialize
 * @param {WeakSet} privateSet - WeakSet to track private method access
 */
function _class_private_method_init(obj, privateSet): void;

_class_private_method_set

Throws error when attempting to set a private method (read-only).

/**
 * Throws error when attempting to set a private method
 * @throws {TypeError} Private methods are read-only
 */
function _class_private_method_set(): never;

Private Static Fields

_class_static_private_field_spec_get

Gets the value of a private static field.

/**
 * Gets the value of a private static field
 * @param {Object} receiver - The class or instance
 * @param {Function} classConstructor - The class constructor
 * @param {Object} descriptor - Private field descriptor
 * @returns {any} The private static field value
 */
function _class_static_private_field_spec_get(receiver, classConstructor, descriptor): any;

_class_static_private_field_spec_set

Sets the value of a private static field.

/**
 * Sets the value of a private static field
 * @param {Object} receiver - The class or instance
 * @param {Function} classConstructor - The class constructor
 * @param {Object} descriptor - Private field descriptor
 * @param {any} value - Value to set
 * @returns {any} The set value
 */
function _class_static_private_field_spec_set(receiver, classConstructor, descriptor, value): any;

_class_static_private_field_update

Updates a private static field with an operation.

/**
 * Updates a private static field with an operation
 * @param {Object} receiver - The class or instance
 * @param {Function} classConstructor - The class constructor
 * @param {Object} descriptor - Private field descriptor
 * @param {Function} updateFn - Update function
 * @returns {any} The updated value
 */
function _class_static_private_field_update(receiver, classConstructor, descriptor, updateFn): any;

_class_static_private_field_destructure

Handles destructuring of private static fields.

/**
 * Handles destructuring of private static fields
 * @param {Object} receiver - The class or instance
 * @param {Function} classConstructor - The class constructor
 * @param {Object} descriptor - Private field descriptor
 * @returns {any} The private static field value for destructuring
 */
function _class_static_private_field_destructure(receiver, classConstructor, descriptor): any;

Private Static Methods

_class_static_private_method_get

Gets a private static method.

/**
 * Gets a private static method
 * @param {Object} receiver - The class or instance
 * @param {Function} classConstructor - The class constructor
 * @param {Function} method - The private static method
 * @returns {Function} The private static method
 */
function _class_static_private_method_get(receiver, classConstructor, method): Function;

Private Field Utilities

_class_check_private_static_access

Checks access to private static members.

/**
 * Checks access to private static members
 * @param {Object} receiver - The receiver object
 * @param {Function} classConstructor - The class constructor
 * @throws {TypeError} If access is invalid
 */
function _class_check_private_static_access(receiver, classConstructor): void;

_class_check_private_static_field_descriptor

Checks private static field descriptor validity.

/**
 * Checks private static field descriptor validity
 * @param {Object} descriptor - Field descriptor to check
 * @param {string} action - Action being performed
 * @throws {TypeError} If descriptor is invalid for action
 */
function _class_check_private_static_field_descriptor(descriptor, action): void;

_check_private_redeclaration

Checks for private field redeclaration errors.

/**
 * Checks for private field redeclaration errors
 * @param {Object} obj - Object being checked
 * @param {WeakMap|WeakSet} privateCollection - Private field collection
 * @throws {SyntaxError} If private field already declared
 */
function _check_private_redeclaration(obj, privateCollection): void;

Loose Mode Private Fields

_class_private_field_loose_base

Gets the base object for loose mode private field access.

/**
 * Gets the base object for loose mode private field access
 * @param {Object} receiver - The receiver object
 * @param {Object} privateKey - Private field key
 * @returns {Object} Base object for private field access
 */
function _class_private_field_loose_base(receiver, privateKey): Object;

_class_private_field_loose_key

Gets the key for loose mode private field access.

/**
 * Gets the key for loose mode private field access
 * @param {string} name - Private field name
 * @returns {string} Mangled private field key
 */
function _class_private_field_loose_key(name): string;

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