isNodeValue()
Function in IR
Runtime type guard for "is this value a node".
import { isNodeValue } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
const isNodeValue: (v: unknown) => v is ReadonlyNodeParameters
vunknown
Return value
v is ReadonlyNode
Description
Runtime type guard for “is this value a node”. It reads the NODE_BRAND slot instead
of using instanceof Node, so it also recognizes a node built by a different loaded copy of
this package, which instanceof would miss because a dual-loaded dependency splits
prototype identity. Use it over instanceof anywhere a value may come from another copy.
Examples
Example
import { isNodeValue, f32 } from 'typeshade'
isNodeValue(f32(1)) // trueisNodeValue(42) // false: a bare number is not a nodeSee also
Source
src/core/ir/node.ts, line 167, at commit 26de7be8