Skip to main content

StaticJsValue

The union of all values that can exist inside a StaticJs sandbox.

Import

import { type StaticJsValue, isStaticJsValue } from "@suntime-js/core";

Overview

StaticJsValue is the top-level type for anything produced or consumed by the evaluator. Every sandbox value is a StaticJsValue.

All values carry a realm reference and implement the StaticJsPrimitive base interface. Object-like values additionally implement StaticJsObject.

Values created by one realm cannot be shared with another realm.

Member types

TypeDescriptionType guard
StaticJsStringA sandboxed stringisStaticJsString
StaticJsNumberA sandboxed numberisStaticJsNumber
StaticJsBooleanA sandboxed booleanisStaticJsBoolean
StaticJsNullThe sandboxed nullisStaticJsNull
StaticJsUndefinedThe sandboxed undefinedisStaticJsUndefined
StaticJsSymbolA sandboxed symbolisStaticJsSymbol
StaticJsPlainObjectA plain sandbox objectisStaticJsPlainObject
StaticJsArrayA sandbox arrayisStaticJsArray
StaticJsFunctionA sandbox functionisStaticJsFunction

Two grouping supertypes are also useful:

SupertypeCoversType guard
StaticJsScalarString, Number, Boolean, Null, Undefined, SymbolisStaticJsScalar
StaticJsObjectPlainObject, Array, Function, Symbol, ProxyisStaticJsObject

Note that StaticJsSymbol appears in both groups: it is a scalar in JavaScript semantics but implements the full StaticJsObject interface internally to support Symbol.prototype method access.


Type guard

isStaticJsValue(value)

isStaticJsValue(value: unknown): value is StaticJsValue

Returns true if value is any sandbox value. Useful as a narrowing check before passing values to APIs that expect StaticJsValue.