Advanced ECMAScript operations from ES2015-ES2019 including function calls, iterators, promises, symbols, typed arrays, and async operations.
Enhanced function calling and property access operations that provide the foundation for modern JavaScript functionality.
/**
* Calls a function with specified this value and arguments
* @param F - Function to call
* @param V - This value for the call
* @param argumentsList - Optional array of arguments
* @returns Result of the function call
*/
function Call(F: Function, V: any, argumentsList?: any[]): any;
/**
* Gets a property value from an object
* @param O - Object to get property from
* @param P - Property key to get
* @returns Property value
*/
function Get(O: object, P: PropertyKey): any;
/**
* Gets a property value using ToObject coercion
* @param V - Value to coerce to object
* @param P - Property key to get
* @returns Property value
*/
function GetV(V: any, P: PropertyKey): any;
/**
* Gets a method from an object
* @param V - Object to get method from
* @param P - Property key of the method
* @returns Function or undefined
*/
function GetMethod(V: any, P: PropertyKey): Function | undefined;
/**
* Determines if object has a property
* @param O - Object to check
* @param P - Property key to check for
* @returns true if property exists
*/
function HasProperty(O: object, P: PropertyKey): boolean;
/**
* Determines if object has an own property
* @param O - Object to check
* @param P - Property key to check for
* @returns true if own property exists
*/
function HasOwnProperty(O: object, P: PropertyKey): boolean;
/**
* Creates a data property on an object
* @param O - Target object
* @param P - Property key
* @param V - Property value
* @returns true if property was created successfully
*/
function CreateDataProperty(O: object, P: PropertyKey, V: any): boolean;
/**
* Creates a data property or throws on failure
* @param O - Target object
* @param P - Property key
* @param V - Property value
* @returns true if successful
*/
function CreateDataPropertyOrThrow(O: object, P: PropertyKey, V: any): boolean;
/**
* Defines a property or throws on failure
* @param O - Target object
* @param P - Property key
* @param desc - Property descriptor
* @returns true if successful
*/
function DefinePropertyOrThrow(O: object, P: PropertyKey, desc: PropertyDescriptor): boolean;
/**
* Deletes a property or throws on failure
* @param O - Target object
* @param P - Property key to delete
* @returns true if successful
*/
function DeletePropertyOrThrow(O: object, P: PropertyKey): boolean;Usage Examples:
const Call = require('es-abstract/2015/Call');
const Get = require('es-abstract/2015/Get');
const HasProperty = require('es-abstract/2015/HasProperty');
// Function calling
function greet(name) { return `Hello, ${name}!`; }
console.log(Call(greet, null, ['World'])); // 'Hello, World!'
// Property access
const obj = { name: 'Alice', age: 30 };
console.log(Get(obj, 'name')); // 'Alice'
console.log(HasProperty(obj, 'toString')); // true (inherited)Iterator protocol operations for working with iterable objects and iterator results.
/**
* Gets an iterator from an object
* @param obj - Object to get iterator from
* @param method - Optional iterator method
* @returns Iterator record
*/
function GetIterator(obj: any, method?: Function): IteratorRecord;
/**
* Calls the next method of an iterator
* @param iteratorRecord - Iterator record to advance
* @param value - Optional value to pass to next
* @returns Iterator result object
*/
function IteratorNext(iteratorRecord: IteratorRecord, value?: any): IteratorResult;
/**
* Closes an iterator
* @param iteratorRecord - Iterator record to close
* @param completion - Optional completion record
* @returns Completion record
*/
function IteratorClose(iteratorRecord: IteratorRecord, completion?: CompletionRecord): CompletionRecord;
/**
* Gets the done flag from an iterator result
* @param iterResult - Iterator result object
* @returns Boolean indicating if iterator is done
*/
function IteratorComplete(iterResult: IteratorResult): boolean;
/**
* Gets the value from an iterator result
* @param iterResult - Iterator result object
* @returns Value from the iterator result
*/
function IteratorValue(iterResult: IteratorResult): any;
/**
* Creates an iterator result object
* @param value - Value for the result
* @param done - Done flag for the result
* @returns Iterator result object
*/
function CreateIterResultObject(value: any, done: boolean): IteratorResult;Usage Examples:
const GetIterator = require('es-abstract/2015/GetIterator');
const IteratorNext = require('es-abstract/2015/IteratorNext');
const IteratorValue = require('es-abstract/2015/IteratorValue');
// Working with iterators
const arr = [1, 2, 3];
const iteratorRecord = GetIterator(arr);
const result1 = IteratorNext(iteratorRecord);
console.log(IteratorValue(result1)); // 1Enhanced array creation and manipulation operations.
/**
* Creates an array with specified length
* @param length - Length of the array to create
* @returns New array with specified length
*/
function ArrayCreate(length: number): any[];
/**
* Sets the length property of an array
* @param A - Target array
* @param Desc - Property descriptor for length
* @returns true if successful
*/
function ArraySetLength(A: any[], Desc: PropertyDescriptor): boolean;
/**
* Creates an array using species constructor
* @param originalArray - Original array
* @param length - Length of new array
* @returns New array created using species constructor
*/
function ArraySpeciesCreate(originalArray: any[], length: number): any[];
/**
* Creates a list from an array-like object
* @param obj - Array-like object
* @param elementTypes - Optional array of allowed element types
* @returns List created from the array-like object
*/
function CreateListFromArrayLike(obj: any, elementTypes?: string[]): any[];String manipulation and processing operations.
/**
* Advances a string index considering Unicode
* @param S - String to advance in
* @param index - Current index
* @param unicode - Whether to consider Unicode
* @returns Advanced index
*/
function AdvanceStringIndex(S: string, index: number, unicode: boolean): number;
/**
* Creates HTML markup with specified tag and attributes
* @param string - String content
* @param tag - HTML tag name
* @param attribute - Attribute name
* @param value - Attribute value
* @returns HTML string
*/
function CreateHTML(string: string, tag: string, attribute: string, value: string): string;
/**
* Performs string substitution for replace operations
* @param matched - Matched substring
* @param str - Original string
* @param position - Position of match
* @param captures - Array of capture groups
* @param namedCaptures - Named capture groups
* @param replacement - Replacement string
* @returns Substituted string
*/
function GetSubstitution(matched: string, str: string, position: number, captures: string[], namedCaptures: object, replacement: string): string;Symbol-related operations for working with ECMAScript symbols.
/**
* Creates a descriptive string for a symbol
* @param sym - Symbol to create description for
* @returns Descriptive string
*/
function SymbolDescriptiveString(sym: symbol): string;Operations for working with ArrayBuffers, DataViews, and typed arrays.
/**
* Detaches an ArrayBuffer
* @param arrayBuffer - ArrayBuffer to detach
* @returns undefined
*/
function DetachArrayBuffer(arrayBuffer: ArrayBuffer): undefined;
/**
* Gets a value from a buffer
* @param arrayBuffer - Source ArrayBuffer
* @param byteIndex - Byte index to read from
* @param type - Type of value to read
* @param isLittleEndian - Endianness flag
* @returns Value read from buffer
*/
function GetValueFromBuffer(arrayBuffer: ArrayBuffer, byteIndex: number, type: string, isLittleEndian: boolean): any;
/**
* Sets a value in a buffer
* @param arrayBuffer - Target ArrayBuffer
* @param byteIndex - Byte index to write to
* @param type - Type of value to write
* @param value - Value to write
* @param isLittleEndian - Endianness flag
* @returns undefined
*/
function SetValueInBuffer(arrayBuffer: ArrayBuffer, byteIndex: number, type: string, value: any, isLittleEndian: boolean): undefined;Operations for working with object prototypes.
/**
* Gets the prototype from a constructor
* @param constructor - Constructor function
* @param intrinsicDefaultProto - Default prototype intrinsic
* @returns Prototype object
*/
function GetPrototypeFromConstructor(constructor: Function, intrinsicDefaultProto: string): object;
/**
* Gets the prototype of an object (ordinary objects)
* @param O - Object to get prototype of
* @returns Prototype object or null
*/
function OrdinaryGetPrototypeOf(O: object): object | null;
/**
* Sets the prototype of an object (ordinary objects)
* @param O - Object to set prototype of
* @param V - New prototype value
* @returns true if successful
*/
function OrdinarySetPrototypeOf(O: object, V: object | null): boolean;Operations supporting regular expression functionality.
/**
* Creates a character range for regular expressions
* @param A - Start character
* @param B - End character
* @returns Character range set
*/
function CharacterRange(A: string, B: string): any[];
/**
* Canonicalizes a character for regular expressions
* @param ch - Character to canonicalize
* @returns Canonicalized character
*/
function Canonicalize(ch: string): string;
/**
* Determines if a character is a word character
* @param e - Character to test
* @returns true if character is a word character
*/
function IsWordChar(e: string): boolean;// Import operations from specific editions
const ES2015 = require('es-abstract/es2015');
const ES2016 = require('es-abstract/es2016');
// Import individual operations (recommended)
const Call = require('es-abstract/2015/Call');
const GetIterator = require('es-abstract/2015/GetIterator');
const ArrayCreate = require('es-abstract/2015/ArrayCreate');