mongez-supportive-is-collections

Provide shape and emptiness predicates for JavaScript values.

12|3|Updated Nov 29, 2017
One-click install
npx skills add https://github.com/hassanzohdy/supportive-is --skill mongez-supportive-is-collections
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mongez-supportive-is-collections
Source: https://github.com/hassanzohdy/supportive-is/tree/main/skills/collections
Command: npx skills add https://github.com/hassanzohdy/supportive-is --skill mongez-supportive-is-collections

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers need reliable predicates to determine the shape and emptiness of values in JavaScript without pulling in heavy utilities. This skill provides a focused set of shape checks to distinguish objects, arrays, iterables, and emptiness, enabling safer data flows and validation.

Core Features & Use Cases

  • isObject: truthy when the value is any object type, including arrays, dates, and class instances, minus null and functions.
  • isPlainObject: true only for plain objects like {} or Object.create(null) with null prototype edge cases.
  • Is.array: true for literal arrays, false for array-like or other iterables.
  • isIterable: true for values with a [Symbol.iterator] method, including strings and collections.
  • isEmpty: smart emptiness with nuanced rules for null, undefined, empty strings, zero values, maps/sets, and plain objects.

Quick Start

Import the predicates from @mongez/supportive-is and begin using isObject, isPlainObject, Is.array, isIterable, and isEmpty in your validation logic.

Frequently Asked Questions about mongez-supportive-is-collections

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check if a JavaScript value is an empty object, array, or string?

Use the isEmpty predicate to check emptiness across JavaScript values. It applies nuanced rules for null, undefined, empty strings, zero values, maps, sets, and plain objects, distinguishing true emptiness across multiple data types for safer validation.

What is the difference between a plain object and a regular object in JavaScript?

A plain object in JavaScript is specifically created via object literals or Object.create(null). The isPlainObject predicate checks for this exact shape, while isObject returns true for any object type including arrays, dates, and class instances minus null.

How do I check if a value is an iterable in JavaScript without heavy utility libraries?

Use the isIterable predicate to check if a JavaScript value has a [Symbol.iterator] method. It identifies iterables including strings and collections without requiring heavy runtime dependencies.

Does this JavaScript object shape predicate library work with zero runtime dependencies?

Yes, these JavaScript object shape and emptiness predicates work with zero runtime dependencies. You can safely import isObject, isPlainObject, Is.array, isIterable, and isEmpty into your validation logic without adding extra package weight to your project.

How do I verify a value is a literal array and not an array-like or iterable object?

To verify a value is a literal array and not an array-like object, use a strict array check predicate. The Is.array function returns true for literal arrays and false for array-like or other iterables, ensuring precise shape prediction for data validation.

When should I use isObject instead of isPlainObject for JavaScript type checking?

Use isObject for JavaScript type checking when you need to validate any object type including arrays, dates, and class instances. Use isPlainObject when you specifically require the value to be a plain object literal or an object with a null prototype edge case.