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"); // falseisString(value)
Checks whether the given value is a string.
isString("hello"); // true
isString(""); // true
isString(42); // falseisBoolean(value)
Checks whether the given value is a boolean.
isBoolean(true); // true
isBoolean(false); // true
isBoolean(1); // falseisBigint(value)
Checks whether the given value is a bigint.
isBigint(123n); // true
isBigint(123); // falseisFunction(value)
Checks whether the given value is a function.
isFunction(() => {}); // true
isFunction(function () {}); // true
isFunction(class Test {}); // true
isFunction(42); // falseisObject(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); // falseisAnArray(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:
NaNandInfinity- Sparse arrays
nullandundefined- Functions, classes, and arrow functions
๐ฏ Use Cases
- Input validation
- Form data checks
- Frontend and backend utility helpers
- Safer JavaScript type handling
๐ License
MIT
๐ Links
- GitHub Repository: https://github.com/phane-tech/js-data-type-check
- Demo / Documentation: https://phane-tech.github.io/js-data-type-check/module-DataTypeCheck.html
- Unit Test Cases Reports: https://phane-tech.github.io/js-data-type-check/unit-test-report.html
FOR RUNKIT
const { isString, isAnArray } = require("phane-js-utils");
console.log(isString("Hi")); // true
console.log(isAnArray([1,2,3])); // true