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 🙏

© 2024 – Pkg Stats / Ryan Hefner

types-checker-js

v1.0.3

Published

A comprehensive utility library for checking and processing various data types in JavaScript. Includes functions for validating arrays, dates, IP addresses, objects, promises, functions, strings, and UUIDs. Suitable for both frontend and backend developer

Downloads

6

Readme

types-checker.js

types-checker.js is a utility library for checking and processing various data types in JavaScript.

Installation

You can install types-checker.js using npm:

npm install types-checker.js
const typesChecker = require('types-checker.js');

// Example usage
const isString = typesChecker.isString('Hello, world!');
console.log(isString); // Output: true

const isArray = typesChecker.isArray([1, 2, 3]);
console.log(isArray); // Output: true

const isDate = typesChecker.isDate(new Date());
console.log(isDate); // Output: true

Primitive Types Checking Functions

  • isNumber(value): Checks if the value is a number.

  • isString(value): Checks if the value is a string.

  • isBoolean(value): Checks if the value is a boolean.

  • isUndefined(value): Checks if the value is undefined.

  • isSymbol(value): Checks if the value is a symbol.

  • isBigInt(value): Checks if the value is a BigInt.

String Checking Functions

  • isString(value): Checks if the value is a string.

  • isNonEmptyString(value): Checks if the value is a non-empty string.

  • isAlpha(value): Checks if the string consists only of alphabetic characters.

  • isAlphanumeric(value): Checks if the string consists of alphanumeric characters.

  • isEmail(value): Checks if the string is a valid email address.

  • isUrl(value): Checks if the string is a valid URL.

Array Checking Functions

  • isArray(value): Checks if the value is an array.
  • isArrayOfNumbers(value): Checks if every element in the array is a number.
  • isArrayOfStrings(value): Checks if every element in the array is a string.
  • isArrayOfObjects(value): Checks if every element in the array is an object.
  • isArrayOfBooleans(value): Checks if every element in the array is a boolean value (true or false).
  • isArrayOf(type, value): Checks if every element in the array is of the specified type.

Date Checking Functions

  • isDate(value): Checks if the value is a Date object.

  • isBeforeDate(value, referenceDate): Checks if the given date is before the reference date.

  • isAfterDate(value, referenceDate): Checks if the given date is after the reference date.

  • isDateInRange(value, startDate, endDate): Checks if the given date is within the specified date range.

Function Checking Functions

  • isFunction(value): Checks if the value is a function.

  • hasArity(value, expectedArity): Checks if the function has the expected number of parameters (arity).

  • hasMinArity(value, minArity): Checks if the function has at least the specified minimum number of parameters.

  • hasMaxArity(value, maxArity): Checks if the function has at most the specified maximum number of parameters.

  • isAsyncFunction(value): Checks if the value is an asynchronous function (async function).

  • isGeneratorFunction(value): Checks if the value is a generator function.

  • isConstructor(value): Checks if the value is a constructor function (can be used with the 'new' keyword).

Object Checking Functions

  • isObject(value): Checks if the value is an object.

  • isObjectWithKeys(value, keys): Checks if the object has all the specified keys.

  • isObjectOf(value, key, type): Checks if the value of the specified key in the object is of the specified type.

  • isObjectWithKeysAndTypes(value, keyTypeMap): Checks if the object has keys matching the specified types.

  • isObjectWithNestedObjects(value): Checks if the object contains nested objects.

Promise Checking Functions

  • isPromise(value): Checks if the value is a Promise.

  • isFulfilledPromise(value): Checks if the value is a fulfilled Promise (resolved).

  • isRejectedPromise(value): Checks if the value is a rejected Promise.

  • isPendingPromise(value): Checks if the value is a pending Promise

IP Checking Functions

  • isIPv4(value): Checks if the value is a valid IPv4 address.

  • isIPv6(value): Checks if the value is a valid IPv6 address.

UUID Checking Functions

  • isUUID(value): Checks if the value is a valid UUID (any version).

  • isUUIDv3(value): Checks if the value is a valid UUIDv3.

  • isUUIDv4(value): Checks if the value is a valid UUIDv4.

  • isUUIDv5(value): Checks if the value is a valid UUIDv5.