ECMAScript spec abstract operations.
npx @tessl/cli install tessl/npm-es-abstract@1.24.0ES Abstract provides comprehensive implementations of ECMAScript specification abstract operations. It exposes over 2000 operations from ES5 through ES2025, enabling developers to access the same primitive operations that JavaScript engines use internally for type checking, conversion, property access, and other fundamental language behaviors.
npm install es-abstract// Main export - all operations as properties
const ES = require('es-abstract');
// Edition-specific imports
const ES2025 = require('es-abstract/es2025');
const ES2020 = require('es-abstract/es2020');
const ES5 = require('es-abstract/es5');Deep imports (recommended for tree-shaking):
// Individual operations
const Call = require('es-abstract/2025/Call');
const Type = require('es-abstract/5/Type');
const ToNumber = require('es-abstract/2020/ToNumber');const ES = require('es-abstract');
// Type checking
console.log(ES.Type(42)); // 'Number'
console.log(ES.Type('hello')); // 'String'
console.log(ES.Type({})); // 'Object'
// Type conversions
console.log(ES.ToNumber('123')); // 123
console.log(ES.ToString(456)); // '456'
console.log(ES.ToBoolean(0)); // false
// Function operations
function myFunc() { return 'called'; }
console.log(ES.IsCallable(myFunc)); // true
console.log(ES.Call(myFunc, null)); // 'called'ES Abstract is organized around ECMAScript specification editions, with each edition building upon previous ones:
Basic ECMAScript 5 abstract operations including type system, comparisons, property descriptors, and date/time operations.
// Type system operations
function Type(x: any): 'Undefined' | 'Null' | 'Boolean' | 'Number' | 'String' | 'Object';
function ToBoolean(argument: any): boolean;
function ToNumber(argument: any): number;
function ToString(argument: any): string;
function ToObject(argument: any): object;
// Comparison operations
function SameValue(x: any, y: any): boolean;
function IsCallable(argument: any): boolean;Advanced operations from ES2015 onwards including function calls, iterators, promises, symbols, and typed arrays.
// Function and property operations
function Call(F: Function, V: any, argumentsList?: any[]): any;
function Get(O: object, P: PropertyKey): any;
function HasProperty(O: object, P: PropertyKey): boolean;
// Iterator operations
function GetIterator(obj: any, method?: Function): IteratorRecord;
function IteratorNext(iteratorRecord: IteratorRecord, value?: any): IteratorResult;
function IteratorClose(iteratorRecord: IteratorRecord, completion?: CompletionRecord): CompletionRecord;Cutting-edge operations from recent ECMAScript editions including BigInt, WeakRef, Promise combinators, and advanced array methods.
// BigInt operations (ES2020+)
function ToBigInt(argument: any): bigint;
function BigIntBitwiseOp(op: string, x: bigint, y: bigint): bigint;
// Advanced array operations (ES2023+)
function FindViaPredicate(O: any[], predicate: Function, fromEnd?: boolean): any;
// Set operations (ES2025+)
function GetSetRecord(obj: any): SetRecord;Shared utilities and record type validators that support the main abstract operations.
// Type checking helpers
function IsArray(argument: any): boolean;
function isObject(argument: any): boolean;
function isPrimitive(argument: any): boolean;
// Record validators
function isPropertyDescriptor(Desc: any): boolean;
function isIteratorRecord(record: any): boolean;// Iterator-related types
interface IteratorRecord {
'[[Iterator]]': object;
'[[NextMethod]]': Function;
'[[Done]]': boolean;
}
interface IteratorResult {
value: any;
done: boolean;
}
// Property descriptor types
interface PropertyDescriptor {
'[[Value]]'?: any;
'[[Writable]]'?: boolean;
'[[Get]]'?: Function;
'[[Set]]'?: Function;
'[[Enumerable]]'?: boolean;
'[[Configurable]]'?: boolean;
}
// Completion record type
interface CompletionRecord {
'[[Type]]': 'normal' | 'throw' | 'return';
'[[Value]]': any;
'[[Target]]': string;
}