js-utils-checkers
v1.0.2
Published
A collection of common JavaScript utility functions like isEmpty, isObject, isToday, etc.
Maintainers
Readme
js-utils-checkers
About js-utils-checkers
js-utils-checkers is a lightweight JavaScript utility package that provides commonly needed type and value checking functions.
Features
- Simple and reusable utility functions
- Helpful for both frontend and backend JavaScript/Node.js projects
- Zero dependencies
📦 Installation
npm install js-utils-checkers
# or
yarn add js-utils-checkers🚀 Usage
import {
isEmpty,
isNullOrUndefined,
isEmptyArray,
isObject,
isToday
} from 'js-utils-checkers';
console.log(isEmpty('')); // true
console.log(isObject({})); // true
console.log(isToday(new Date())); // true🧰 Available Functions
🔹 isEmpty(value)
Returns true if the value is:
nullundefined- an empty string
'' - an empty array
[]
Example:
isEmpty(null); // true
isEmpty(undefined); // true
isEmpty(''); // true
isEmpty([]); // true🔹 isNullOrUndefined(value)
Returns true if the value is either null or undefined.
Example:
isNullOrUndefined(null); // true
isNullOrUndefined(undefined); // true🔹 isEmptyArray(arr)
Returns true if the value is an array and is empty.
Example:
isEmptyArray([]); // true
isEmptyArray([1]); // false🔹 isObject(obj)
Returns true if the value is a plain object (i.e., not an array, not null).
Example:
isObject({}); // true
isObject(null); // false🔹 isToday(date)
Checks if a given Date object matches today’s date.
Example:
isToday(new Date()); // true📁 Project Structure
js-utils-checkers/
├── src/
│ └── index.js
├── test.js
├── package.json
├── README.md
├── .gitignore
└── .npmignore 🧪 Local Testing
Create a test file to verify functionality:
import { isEmpty, isObject, isToday } from './src/index.js';
console.log(isEmpty([]));
console.log(isObject({}));
console.log(isToday(new Date()));Run it:
node test.js🤝 Contributing
We welcome contributions!
- Fork the repo
- Create a feature branch
- Commit your changes
- Open a pull request
📜 License
This project is licensed under the MIT License
🙌 Support
If you find this useful, please star the repo or share it with others!
