npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

is-check-js

v1.0.0

Published

A comprehensive utility library for type checking and validation

Readme

is-check-js

A comprehensive utility library for type checking and validation in Node.js and JavaScript applications.

Features

  • Comprehensive Type Checking: Over 30 utility functions for type validation
  • TypeScript Support: Full TypeScript definitions included
  • Zero Dependencies: Lightweight with no external dependencies
  • Well Tested: 100% test coverage with Jest
  • Modern JavaScript: Supports all modern JavaScript types including BigInt and Symbol
  • Advanced Validations: Email, URL, IP address, credit card, and more

Installation

yarn add is-check-js

Quick Start

import { isString, isEmail, isEmpty, isPositive } from 'is-check-js';

// Basic type checking
console.log(isString('hello')); // true
console.log(isString(123)); // false

// Advanced validation
console.log(isEmail('[email protected]')); // true
console.log(isEmpty('')); // true
console.log(isPositive(5)); // true

API Reference

Basic Type Checking

isString(value)

Check if value is a string.

isString('hello'); // true
isString(123); // false

isNumber(value)

Check if value is a number (excluding NaN).

isNumber(123); // true
isNumber('123'); // false
isNumber(NaN); // false

isBoolean(value)

Check if value is a boolean.

isBoolean(true); // true
isBoolean('true'); // false

isFunction(value)

Check if value is a function.

isFunction(() => {}); // true
isFunction(Math.max); // true

isArray(value)

Check if value is an array.

isArray([]); // true
isArray([1, 2, 3]); // true
isArray({}); // false

isObject(value)

Check if value is a plain object (not array, null, or other objects).

isObject({}); // true
isObject({ a: 1 }); // true
isObject([]); // false
isObject(null); // false

isObjectLike(value)

Check if value is any type of object (including arrays, dates, etc.).

isObjectLike({}); // true
isObjectLike([]); // true
isObjectLike(new Date()); // true
isObjectLike(null); // false

isDate(value)

Check if value is a valid Date object.

isDate(new Date()); // true
isDate(new Date('invalid')); // false

isRegExp(value)

Check if value is a RegExp object.

isRegExp(/test/); // true
isRegExp(new RegExp('test')); // true

isNull(value), isUndefined(value), isNil(value)

Check for null, undefined, or both.

isNull(null); // true
isUndefined(undefined); // true
isNil(null); // true
isNil(undefined); // true

isSymbol(value), isBigInt(value)

Check for modern JavaScript types.

isSymbol(Symbol('test')); // true
isBigInt(123n); // true

Advanced Validation

isEmpty(value)

Check if value is empty (works with strings, arrays, objects, Maps, Sets).

isEmpty(''); // true
isEmpty([]); // true
isEmpty({}); // true
isEmpty(null); // true
isEmpty('hello'); // false

isEmail(value)

Validate email addresses.

isEmail('[email protected]'); // true
isEmail('invalid-email'); // false

isURL(value)

Validate URLs.

isURL('https://example.com'); // true
isURL('http://localhost:3000'); // true
isURL('not-a-url'); // false

isPhoneNumber(value)

Basic phone number validation.

isPhoneNumber('1234567890'); // true
isPhoneNumber('+1 (555) 123-4567'); // true

isJSON(value)

Check if string is valid JSON.

isJSON('{"name": "John"}'); // true
isJSON('{invalid}'); // false

Number Validation

isPositive(value), isNegative(value), isZero(value)

Number sign validation.

isPositive(5); // true
isNegative(-3); // true
isZero(0); // true

isInteger(value), isFloat(value)

Number type validation.

isInteger(42); // true
isFloat(3.14); // true

isEven(value), isOdd(value)

Even/odd number validation.

isEven(4); // true
isOdd(3); // true

isInRange(value, min, max)

Check if number is within a range.

isInRange(5, 0, 10); // true
isInRange(15, 0, 10); // false

Advanced Format Validation

isCreditCard(value)

Validate credit card numbers using Luhn algorithm.

isCreditCard('4111111111111111'); // true (Visa test number)

isIPv4(value), isIPv6(value)

IP address validation.

isIPv4('192.168.1.1'); // true
isIPv6('2001:0db8:85a3:0000:0000:8a2e:0370:7334'); // true

isHexColor(value)

Hexadecimal color validation.

isHexColor('#ff5733'); // true
isHexColor('#fff'); // true

isUUID(value)

UUID validation.

isUUID('123e4567-e89b-12d3-a456-426614174000'); // true

Utility Functions

isAny(value, ...predicates)

Check if value matches any of the provided predicates.

isAny('hello', isString, isNumber); // true
isAny(123, isString, isNumber); // true

isAll(value, ...predicates)

Check if value matches all of the provided predicates.

isAll('hello', isString, v => v.length > 0); // true

isType(value, type)

Check if value is of a specific type using string comparison.

isType('hello', 'string'); // true
isType([], 'array'); // true
isType(null, 'null'); // true

isTruthy(value), isFalsy(value)

Check truthiness and falsiness.

isTruthy(1); // true
isFalsy(0); // true

getType(value)

Get the type of a value as a string.

getType('hello'); // 'string'
getType([]); // 'array'
getType(null); // 'null'
getType(new Date()); // 'date'

TypeScript Support

The library includes comprehensive TypeScript definitions:

import { isString, isEmail, isEmpty } from 'is-check-js';

const userInput: unknown = getUserInput();

if (isString(userInput)) {
  // TypeScript knows userInput is a string here
  console.log(userInput.toUpperCase());
}

if (isEmail(userInput)) {
  // TypeScript knows userInput is a string (email)
  sendEmail(userInput);
}

Testing

Run the test suite:

yarn test

# Run with coverage
yarn test:coverage

# Run in watch mode
yarn test:watch

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Add tests for your changes
  4. Ensure all tests pass (yarn test)
  5. Commit your changes (git commit -m 'Add some amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

License

MIT License - see the LICENSE file for details.

Changelog

1.0.0

  • Initial release with comprehensive type checking and validation utilities
  • TypeScript support
  • Full test coverage
  • Zero dependencies