core / const
valueIsNonSignalObject
Checks whether a value is a non-signal object, optionally matching specific types.
Checks whether a value is a non-signal object, optionally matching specific types.
Signature
export const valueIsNonSignalObject = (
input: any,
shouldMatchAnyOfTypes?: string[],
): boolean =>
input?.type === "non-signal" &&
(!shouldMatchAnyOfTypes ||
!shouldMatchAnyOfTypes.length ||
shouldMatchAnyOfTypes.some((type) => typeof input?.value === type));
Parameters
(for example,
["string", "number"])
input: Any value to checkshouldMatchAnyOfTypes: Optional array of primitive type names to match
Returns
true if the value has
type: "non-signal" and (if types provided)
the value matches one of the types
Remarks
- Empty types array is treated as no type restriction
- Returns false for
nullandundefined
Examples
const nonSig = getNonSignalObject(42);
valueIsNonSignalObject(nonSig); // true
valueIsNonSignalObject(nonSig, ["number"]); // true
valueIsNonSignalObject(nonSig, ["string"]); // false
See Also
- NonSignal - For non-signal type
- getNonSignalObject - For creating non-signal objects