is-iterable-empty
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

is-iterable-empty

npm version License: MIT

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, otherwise false.

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.

Package Sidebar

Install

npm i is-iterable-empty

Weekly Downloads

4

Version

1.0.0

License

MIT

Unpacked Size

5.62 kB

Total Files

6

Last publish

Collaborators

  • vincenzomaritato