Checks if the given value is primitive. Primitive types include: - number - string - boolean - symbol - bigint - undefined - null
isPrimitive(0); // => trueisPrimitive(null); // => trueisPrimitive(undefined); // => trueisPrimitive("0"); // => false
npx atmx add helper is-primitive
Copy and paste the following method into @/utils/helpers/undefined.ts:
@/utils/helpers/undefined.ts
/*** Checks if the given value is primitive.** Primitive types include:* - number* - string* - boolean* - symbol* - bigint* - undefined* - null** @example* isPrimitive(0) // => true* isPrimitive(null) // => true* isPrimitive(undefined) // => true* isPrimitive('0') // => false*/export function isPrimitive(value: any): boolean {return (value === undefined ||value === null ||(typeof value !== "object" && typeof value !== "function"));}