JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q31871F
  • License MIT

Pure JavaScript utility functions

Package Exports

  • phane-js-utils
  • phane-js-utils/index.cjs
  • phane-js-utils/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (phane-js-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Kotipalli Phaneendra - Data Type Checking

A lightweight, dependency-free JavaScript utility library for data type checking and input validation.
It provides simple helper functions to reliably determine JavaScript data types and safely work with objects and arrays.

Designed to be minimal, predictable, and well-tested, phane-js-utils works seamlessly in both Node.js and browser environments.


โœจ Highlights

  • ๐Ÿ” Simple and reliable type-checking helpers
  • ๐Ÿ“ฆ Object & array utility functions
  • ๐Ÿงช Fully unit-tested with edge cases
  • โšก Zero dependencies
  • ๐ŸŒ Works in Node.js and modern browsers

๐Ÿ“ฆ Installation

npm install phane-js-utils

๐Ÿš€ Quick Example

import {
  isNumber,
  isString,
  isBoolean,
  isAnArray
} from "phane-js-utils";

isNumber(42);        // true
isString("hello");  // true
isBoolean(false);   // true
isAnArray([1, 2, 3]); // true

๐Ÿ“š API Reference

All functions are pure, dependency-free, and follow native JavaScript behavior.


isNumber(value)

Checks whether the given value is a JavaScript number.

isNumber(42);        // true
isNumber(NaN);       // true
isNumber(Infinity);  // true
isNumber("42");      // false

isString(value)

Checks whether the given value is a string.

isString("hello"); // true
isString("");      // true
isString(42);       // false

isBoolean(value)

Checks whether the given value is a boolean.

isBoolean(true);   // true
isBoolean(false);  // true
isBoolean(1);      // false

isBigint(value)

Checks whether the given value is a bigint.

isBigint(123n); // true
isBigint(123);  // false

isFunction(value)

Checks whether the given value is a function.

isFunction(() => {});        // true
isFunction(function () {});  // true
isFunction(class Test {});   // true
isFunction(42);              // false

isObject(value)

Checks whether the given value is a plain object (not an array, function, or null).

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

isAnArray(value)

Checks whether the given value is an array.

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

๐Ÿงช Testing

All utilities are covered with unit tests, including edge cases such as:

  • NaN and Infinity
  • Sparse arrays
  • null and undefined
  • Functions, classes, and arrow functions

๐ŸŽฏ Use Cases

  • Input validation
  • Form data checks
  • Frontend and backend utility helpers
  • Safer JavaScript type handling

๐Ÿ“„ License

MIT


FOR RUNKIT

const { isString, isAnArray } = require("phane-js-utils");

console.log(isString("Hi"));       // true
console.log(isAnArray([1,2,3]));  // true