isScalar()
Function in Types
Narrows a ShaderType to the native { kind: 'scalar' } arm.
import { isScalar } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
const isScalar: ( t: ShaderType,) => t is Extract<ShaderType, { kind: "scalar"; }>Parameters
Return value
t is Extract<ShaderType, { kind: 'scalar' }>
Description
Narrows a ShaderType to the native { kind: 'scalar' } arm (f32, i32, u32, bool).
It is false for f64T, which is its own kind so that this predicate does not treat
it as a scalar. Arithmetic type resolution uses it to detect the vector-scalar broadcast
case (isVec(a) && isScalar(b) and its mirror), where the vector operand’s type is the
result.
Examples
Example
import { isScalar, f32T, f64T } from 'typeshade'
isScalar(f32T) // trueisScalar(f64T) // false: f64 is its own ShaderType kindSee also
Source
src/core/ir/types.ts, line 1089, at commit 26de7be8