@dephub/is
v1.1.0
Published
A lightweight runtime type guard library for JavaScript & TypeScript
Maintainers
Readme
@dephub/is 🧩
Lightweight runtime type guards for JavaScript & TypeScript
Features ✨
- 🛡️ Primitives:
string,number,boolean,bigint,symbol,undefined,null,NaN - 🔹 Advanced types:
array,object,function,map,set,promise,error,date,regexp,response - ⚡ Utilities:
isEmpty,isTruthy,isFalsy,isPrimitive - 🔄 Fully TypeScript safe with type predicates for narrowing
Installation 📦
# npm
npm install @dephub/is
# pnpm
pnpm add @dephub/is
# yarn
yarn add @dephub/is
# bun
bun add @dephub/isUsage 🎯
import {
// Primitives
isString,
isNumber,
isBoolean,
isBigInt,
isSymbol,
isUndefined,
isNull,
isNaN,
// Advanced
isArray,
isObject,
isFunction,
isMap,
isSet,
isPromise,
isError,
isDate,
isRegExp,
isResponse,
// Utilities
isEmpty,
isTruthy,
isFalsy,
isPrimitive,
// Type helper
typeOf,
} from '@dephub/is';
// Primitives
isString('hello'); // true
isNumber(42); // true
isBoolean(false); // true
// Objects & collections
isArray([1, 2, 3]); // true
isObject({ a: 1 }); // true
isMap(new Map()); // true
isSet(new Set()); // true
// Functions & errors
isFunction(() => {}); // true
isError(new Error('oops')); // true
// Special objects
isDate(new Date()); // true
isRegExp(/abc/); // true
isResponse(new Response()); // true
// Async
isPromise(Promise.resolve()); // true
// Utilities
isEmpty([]); // true
isTruthy('value'); // true
isFalsy(0); // true
isPrimitive(42); // true
// Type check helper
typeOf(null); // 'null'
typeOf([1, 2, 3]); // 'array'
typeOf(Promise.resolve()); // 'promise'License 📄
MIT License – see LICENSE for details.
Author: Estarlin R (estarlincito.com)
