CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-es-abstract

ECMAScript spec abstract operations.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

latest-features.mddocs/

Latest Features

Cutting-edge ECMAScript operations from ES2020-ES2025 including BigInt, WeakRef, Promise combinators, advanced array methods, and the most recent language additions.

Capabilities

Type Conversion Operations (ES2020+)

Enhanced type conversion operations for modern JavaScript including BigInt compatibility.

/**
 * Converts a value to a numeric value (Number or BigInt)
 * @param argument - Value to convert to numeric type
 * @returns Number or BigInt representation of the argument
 */
function ToNumeric(argument: any): number | bigint;

/**
 * Converts a value to an integer or ±Infinity (replaces ToInteger)
 * @param argument - Value to convert
 * @returns Integer value or ±Infinity
 */
function ToIntegerOrInfinity(argument: any): number;

BigInt Operations (ES2020+)

Operations for working with arbitrary precision integers introduced in ES2020.

/**
 * Converts a value to BigInt
 * @param argument - Value to convert to BigInt
 * @returns BigInt representation of the argument
 */
function ToBigInt(argument: any): bigint;

/**
 * Converts a value to BigInt64 (64-bit signed)
 * @param argument - Value to convert
 * @returns 64-bit signed BigInt
 */
function ToBigInt64(argument: any): bigint;

/**
 * Converts a value to BigUint64 (64-bit unsigned)
 * @param argument - Value to convert
 * @returns 64-bit unsigned BigInt
 */
function ToBigUint64(argument: any): bigint;

/**
 * Performs BigInt bitwise operations
 * @param op - Operation type ('&', '|', '^')
 * @param x - First BigInt operand
 * @param y - Second BigInt operand
 * @returns Result of bitwise operation
 */
function BigIntBitwiseOp(op: string, x: bigint, y: bigint): bigint;

/**
 * Converts Number to BigInt
 * @param number - Number to convert
 * @returns BigInt representation
 */
function NumberToBigInt(number: number): bigint;

/**
 * Creates a BigInt primitive from constructor argument
 * @param argument - Value to convert to BigInt
 * @returns BigInt primitive value
 */
function BigInt(argument: any): bigint;

Usage Examples:

const ToNumeric = require('es-abstract/2020/ToNumeric');
const ToIntegerOrInfinity = require('es-abstract/2021/ToIntegerOrInfinity');

// Type conversion operations
console.log(ToNumeric('123'));      // 123 (Number)
console.log(ToNumeric('123n'));     // 123n (BigInt)
console.log(ToIntegerOrInfinity(3.7)); // 3
console.log(ToIntegerOrInfinity(-3.7)); // -3

const ToBigInt = require('es-abstract/2020/ToBigInt');
const BigIntBitwiseOp = require('es-abstract/2020/BigIntBitwiseOp');

// BigInt conversions
console.log(ToBigInt('123'));        // 123n
console.log(ToBigInt(456));          // 456n

// BigInt operations
const a = ToBigInt('18446744073709551615');
const b = ToBigInt('255');
console.log(BigIntBitwiseOp('&', a, b)); // 255n

Advanced Array Operations (ES2021+)

Enhanced array processing operations supporting modern array methods.

/**
 * Flattens array elements into a target array
 * @param target - Target array to flatten into
 * @param original - Source array
 * @param depth - Flattening depth
 * @param mapperFunction - Optional mapper function
 * @param thisArg - Optional this value for mapper
 * @returns Length of flattened array
 */
function FlattenIntoArray(target: any[], original: any[], depth: number, mapperFunction?: Function, thisArg?: any): number;

/**
 * Finds array element via predicate function
 * @param O - Array-like object to search
 * @param predicate - Predicate function
 * @param fromEnd - Whether to search from end (findLast)
 * @returns Found element or undefined
 */
function FindViaPredicate(O: any[], predicate: Function, fromEnd?: boolean): any;

/**
 * Compares array elements for sorting
 * @param x - First element
 * @param y - Second element
 * @param comparefn - Optional compare function
 * @returns Comparison result (-1, 0, 1)
 */
function CompareArrayElements(x: any, y: any, comparefn?: Function): number;

/**
 * Compares typed array elements for sorting
 * @param x - First element
 * @param y - Second element
 * @param comparefn - Optional compare function
 * @returns Comparison result (-1, 0, 1)
 */
function CompareTypedArrayElements(x: any, y: any, comparefn?: Function): number;

Promise Operations (ES2020+)

Advanced promise handling operations for modern asynchronous programming.

/**
 * Gets Promise.resolve function for promise operations
 * @param promiseConstructor - Promise constructor
 * @returns Promise resolve function  
 */
function GetPromiseResolve(promiseConstructor: Function): Function;

WeakRef and FinalizationRegistry (ES2021+)

Operations for weak references and object finalization.

/**
 * Determines if a value can be held weakly
 * @param v - Value to test
 * @returns true if value can be held weakly
 */
function CanBeHeldWeakly(v: any): boolean;

/**
 * Adds an object to kept objects list
 * @param object - Object to keep alive
 * @returns undefined
 */
function AddToKeptObjects(object: any): undefined;

/**
 * Clears the kept objects list
 * @returns undefined
 */
function ClearKeptObjects(): undefined;

Set Operations (ES2025+)

Modern Set utility operations for set-theoretic functions.

/**
 * Gets a Set record from a Set-like object
 * @param obj - Set-like object
 * @returns Set record with set data and operations
 */
function GetSetRecord(obj: any): SetRecord;

/**
 * Groups elements by a key function
 * @param items - Items to group
 * @param callbackfn - Key extraction function
 * @param thisArg - Optional this value
 * @returns Map of grouped items
 */
function GroupBy(items: Iterable<any>, callbackfn: Function, thisArg?: any): Map<any, any[]>;

/**
 * Adds a value to a keyed group
 * @param groups - Map of groups
 * @param key - Group key
 * @param value - Value to add
 * @returns undefined
 */
function AddValueToKeyedGroup(groups: Map<any, any[]>, key: any, value: any): undefined;

String and RegExp Enhancements (ES2025+)

Latest string processing and regular expression operations.

/**
 * Encodes strings for RegExp.escape
 * @param S - String to encode for regex
 * @returns Escaped string safe for regex literals
 */
function EncodeForRegExpEscape(S: string): string;

/**
 * Gets match string from a RegExp result
 * @param match - RegExp match result
 * @returns Matched string
 */
function GetMatchString(match: RegExpMatchArray): string;

/**
 * Gets match index pair from RegExp result
 * @param match - RegExp match result  
 * @param index - Match index
 * @returns Index pair [start, end]
 */
function GetMatchIndexPair(match: RegExpMatchArray, index: number): [number, number];

/**
 * Checks if RegExp has either Unicode flag (u or v)
 * @param R - RegExp to check
 * @returns true if has unicode flag
 */
function HasEitherUnicodeFlag(R: RegExp): boolean;

/**
 * Creates RegExp string iterator
 * @param R - RegExp object
 * @param S - String to iterate over
 * @param global - Whether RegExp is global
 * @param fullUnicode - Whether to use full Unicode
 * @returns RegExp string iterator
 */
function CreateRegExpStringIterator(R: RegExp, S: string, global: boolean, fullUnicode: boolean): any;

Advanced Iterator Operations (ES2023+)

Enhanced iterator operations supporting iterator helpers and advanced iteration patterns.

/**
 * Gets iterator directly without method lookup
 * @param obj - Object with iterator
 * @returns Iterator record
 */
function GetIteratorDirect(obj: any): IteratorRecord;

/**
 * Gets flattening iterator from value
 * @param obj - Object to get flattening iterator from
 * @param stringHandling - How to handle strings
 * @returns Iterator for flattening
 */
function GetIteratorFlattenable(obj: any, stringHandling?: string): any;

/**
 * Gets iterator from method
 * @param obj - Object to get iterator from
 * @param method - Iterator method
 * @returns Iterator record
 */
function GetIteratorFromMethod(obj: any, method: Function): IteratorRecord;

/**
 * Creates iterator from closure function
 * @param closure - Closure function for iteration
 * @param generatorBrand - Generator brand for the iterator
 * @returns Iterator object
 */
function CreateIteratorFromClosure(closure: Function, generatorBrand: string): any;

Temporal Operations (ES2024+)

Time zone and temporal operations for the Temporal proposal.

/**
 * Gets named time zone epoch nanoseconds
 * @param timeZoneIdentifier - Time zone identifier
 * @param year - Year value
 * @param month - Month value
 * @param day - Day value
 * @param hour - Hour value
 * @param minute - Minute value
 * @param second - Second value
 * @param millisecond - Millisecond value
 * @param microsecond - Microsecond value
 * @param nanosecond - Nanosecond value
 * @returns Epoch nanoseconds for the time zone
 */
function GetNamedTimeZoneEpochNanoseconds(
  timeZoneIdentifier: string,
  year: number,
  month: number, 
  day: number,
  hour: number,
  minute: number,
  second: number,
  millisecond: number,
  microsecond: number,
  nanosecond: number
): bigint;

/**
 * Gets UTC epoch nanoseconds
 * @param year - Year value
 * @param month - Month value  
 * @param day - Day value
 * @param hour - Hour value
 * @param minute - Minute value
 * @param second - Second value
 * @param millisecond - Millisecond value
 * @param microsecond - Microsecond value
 * @param nanosecond - Nanosecond value
 * @returns UTC epoch nanoseconds
 */
function GetUTCEpochNanoseconds(
  year: number,
  month: number,
  day: number, 
  hour: number,
  minute: number,
  second: number,
  millisecond: number,
  microsecond: number,
  nanosecond: number
): bigint;

/**
 * Gets system time zone identifier
 * @returns System time zone identifier string
 */
function SystemTimeZoneIdentifier(): string;

ArrayBuffer Enhancements (ES2024+)

Advanced ArrayBuffer operations including transfer capabilities.

/**
 * Copies and detaches an ArrayBuffer
 * @param arrayBuffer - Source ArrayBuffer
 * @param newLength - New length for copied buffer
 * @param preserveResizability - Whether to preserve resizability
 * @returns New ArrayBuffer with copied data
 */
function ArrayBufferCopyAndDetach(arrayBuffer: ArrayBuffer, newLength?: number, preserveResizability?: boolean): ArrayBuffer;

/**
 * Gets ArrayBuffer byte length
 * @param arrayBuffer - ArrayBuffer to get length of
 * @returns Byte length of the ArrayBuffer
 */
function ArrayBufferByteLength(arrayBuffer: ArrayBuffer): number;

/**
 * Gets ArrayBuffer maximum byte length option
 * @param options - Options object
 * @returns Maximum byte length or undefined
 */
function GetArrayBufferMaxByteLengthOption(options: any): number | undefined;

Import Patterns

// Import operations from latest editions
const ES2025 = require('es-abstract/es2025');
const ES2024 = require('es-abstract/es2024');
const ES2020 = require('es-abstract/es2020');

// Import individual operations (recommended)
const ToBigInt = require('es-abstract/2020/ToBigInt');
const FindViaPredicate = require('es-abstract/2023/FindViaPredicate');
const GetSetRecord = require('es-abstract/2025/GetSetRecord');
const EncodeForRegExpEscape = require('es-abstract/2025/EncodeForRegExpEscape');

Install with Tessl CLI

npx tessl i tessl/npm-es-abstract

docs

es5-operations.md

helper-utilities.md

index.md

latest-features.md

modern-operations.md

tile.json