isSymbol
Checks whether a value is a symbol. A symbol is a primitive value created using the Symbol function.
This helper never throws and never mutates input. Use it when you need to confirm symbol types before running normalization or validation.
Signature
function isSymbol(value: unknown): value is symbol
Parameters
| Name | Data type | Description |
|---|---|---|
| value | unknown |
The value to check. This helper returns true only for symbol primitives. |
Returns
A boolean:
trueif the value is a symbol.falseotherwise.
Examples
isSymbol(Symbol()) // true
isSymbol(Symbol('id')) // true
isSymbol(Symbol.iterator) // true
isSymbol(Object(Symbol())) // false
isSymbol("abc") // false
isSymbol(123) // false
Notes
- This helper performs a strict
typeofcheck and does not acceptSymbolwrapper objects. - Use
normalizeSymbolif you need to convert values into symbols. - Use
validateSymbolif you need aResult<T>instead of a boolean.