is-iterable-empty
v1.0.0
Published
A simple utility to check if an Iterable is empty.
Downloads
9
Maintainers
Readme
is-iterable-empty
A simple utility to check if an Iterable (such as arrays, strings, sets, etc.) is empty. Supports all JavaScript iterable data structures.
Installation
You can install the package using npm:
npm install is-iterable-empty
Usage
Import the function into your project and use it to check if an Iterable is empty:
const isIterableEmpty = require('is-iterable-empty');
console.log(isIterableEmpty([])); // true
console.log(isIterableEmpty([1, 2, 3])); // false
console.log(isIterableEmpty('')); // true
console.log(isIterableEmpty('hello')); // false
console.log(isIterableEmpty(new Set())); // true
console.log(isIterableEmpty(new Set([1, 2, 3]))); // false
API
isIterableEmpty(iterable)
iterable
(Iterable): The Iterable object to test.- Return:
boolean
-true
if the Iterable is empty, otherwisefalse
.
Examples
Check Array
const isIterableEmpty = require('is-iterable-empty');
console.log(isIterableEmpty([])); // true
console.log(isIterableEmpty([1, 2, 3])); // false
Check Strings
const isIterableEmpty = require('is-iterable-empty');
console.log(isIterableEmpty('')); // true
console.log(isIterableEmpty('hello')); // false
Check Set
const isIterableEmpty = require('is-iterable-empty');
console.log(isIterableEmpty(new Set())); // true
console.log(isIterableEmpty(new Set([1, 2, 3]))); // false
Contributions
Contributions, bug reports and feature requests are welcome! Feel free to open an issue or pull request.
License
This project is licensed under the MIT License. See the LICENSE file for more details.