Triggers error if arg
is not a primitive type.
The only types considered primitive here are number, string, and boolean.
errorIfNotPrimitive([]);
// Error: "Input must be either a number, string, or boolean"
npm i error-if-not-primitive
// if using TypeScript:
import { errorIfNotPrimitive } from 'error-if-not-primitive';
// if using ES5 JavaScript:
var errorIfNotPrimitive = require('error-if-not-primitive').errorIfNotPrimitive;