isNodeValue()
함수, IR 분류
Runtime type guard for "is this value a node".
import { isNodeValue } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
const isNodeValue: (v: unknown) => v is ReadonlyNode매개변수
vunknown
반환값
v is ReadonlyNode
설명
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.
예제
예제
import { isNodeValue, f32 } from 'typeshade'
isNodeValue(f32(1)) // trueisNodeValue(42) // false: a bare number is not a node함께 보기
소스
src/core/ir/node.ts, 167행, 커밋 c66579bf 기준