Skip to content

Supportive Is

A small library of type and shape predicatesisString, isEmpty, isUrl, isPromise, isMobile.*, and friends. Each one is a named export, so bundlers drop the ones you don’t use. Pure predicates run anywhere; DOM-touching predicates read globals lazily so server-side imports stay safe.

Highlighted features

~60 named predicates

One named export per predicate — isString, isEmail, isUrl, isPromise, isPlainObject, dozens more.

Tree-shake to ~80 bytes

sideEffects: false + per-predicate exports. Pull isEmail alone and ship ~80 bytes, not the whole 3KB bag.

Server-safe imports

DOM/browser predicates read navigator / window / document lazily. Safe to import on the server; isFormElement returns false there instead of throwing.

”Smart” emptiness

isEmpty collapses null / undefined / "" / [] / {} / Maps / Sets into one check. 0 and false are deliberately NOT empty.

Install

Terminal window
npm install @mongez/supportive-is

Quick peek

import { isEmail, isEmpty, isPlainObject, isUrl } from "@mongez/supportive-is";
isEmail("user@example.com"); // true
isEmpty({}); // true
isEmpty(0); // false — zero is a real value
isPlainObject(new Date()); // false — Date is an instance, not a literal
isUrl("https://example.com"); // true

Tree-shakable predicates — import only what you use.

Mental model

ConceptWhat it means
Pure predicatesSingle-argument functions: take a value, return boolean-ish. No side effects, no allocation.
Is namespaceA bag of references to the same functions, kept for v1 compatibility. Doesn’t tree-shake — prefer named imports.
Environment probesTouch navigator / window / document at call time. Server-safe to import, server-unsafe to call.
”Smart” emptinessisEmpty collapses null / undefined / "" / [] / / new Map() / new Set() into one check, with 0 and false deliberately not empty.

Scope boundaries

ConcernLives inWhy
General object/string/array helpers@mongez/reinforcementsDifferent package, different scope
Schema validation (z.string().email())zod, valibotPredicates are guards, not validators
HTML sanitizationDOMPurifyRegex-based stripping is a footgun

Where to go next

  • PrimitivesisString, isNumber, isBoolean, isFunction, etc.
  • CollectionsisArray, isPlainObject, isMap, isSet, isEmpty
  • FormatsisEmail, isUrl, isJson, isIp
  • EnvironmentisBrowser, isMobile, isMac, vendor probes
  • Misc — edge-case predicates
  • Recipes — composition patterns