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
| Type | Description | Type guard |
|---|---|---|
StaticJsString | A sandboxed string | isStaticJsString |
StaticJsNumber | A sandboxed number | isStaticJsNumber |
StaticJsBoolean | A sandboxed boolean | isStaticJsBoolean |
StaticJsNull | The sandboxed null | isStaticJsNull |
StaticJsUndefined | The sandboxed undefined | isStaticJsUndefined |
StaticJsSymbol | A sandboxed symbol | isStaticJsSymbol |
StaticJsPlainObject | A plain sandbox object | isStaticJsPlainObject |
StaticJsArray | A sandbox array | isStaticJsArray |
StaticJsFunction | A sandbox function | isStaticJsFunction |
Two grouping supertypes are also useful:
| Supertype | Covers | Type guard |
|---|---|---|
StaticJsScalar | String, Number, Boolean, Null, Undefined, Symbol | isStaticJsScalar |
StaticJsObject | PlainObject, Array, Function, Symbol, Proxy | isStaticJsObject |
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.