mongez-supportive-is-misc

Document five object-kind predicates from supportive-is with usage guidance.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Documents the five object-kind predicates — isPromise, isDate, isGenerator, isFormElement, and isFormData — including constructor-name semantics and known bugs. This Skill helps developers understand when and how to apply these checks, and to avoid common pitfalls.

Core Features & Use Cases

  • Clear definitions for five predicates and when to use them.
  • Edge-case notes: isDate treats invalid dates as Date instances; isGenerator is duck-typed; isFormElement/isFormData rely on DOM globals.
  • Practical guidance for importing and using in projects that rely on supportive-is.

Quick Start

Explain the five predicates and show example imports and usage.

Frequently Asked Questions about mongez-supportive-is-misc

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

FAQPage Schema
How do I check if an object is a Promise or Date in JavaScript?

To check if an object is a Promise or Date in JavaScript, you use object-kind predicates like isPromise and isDate. These predicates identify object instances by their constructor-name semantics, providing precise type detection across cross-environment code.

Why does isDate return true for invalid dates in JavaScript?

The isDate predicate returns true for invalid dates because it checks the object-kind constructor-name semantics rather than the date's value validity. This means an invalid Date instance is still recognized as a Date object, a known quirk developers must handle when validating JavaScript date values.

How do I detect FormData and FormElement objects in a web environment?

To detect FormData and FormElement objects, you use the isFormData and isFormElement predicates. These checks rely on DOM globals, meaning they function specifically within web environments where DOM APIs are available for identifying form-related object instances.

What is the best way to identify a Generator object in JavaScript?

The best way to identify a Generator object in JavaScript is using the isGenerator predicate. This check is duck-typed, meaning it identifies generators by their structural shape and behavior rather than relying solely on constructor names, avoiding cross-environment prototype issues.

Are supportive-is type predicates safe to use across different JavaScript environments?

Supportive-is type predicates are designed for cross-environment behavior, but they have edge cases. For example, isFormElement and isFormData rely on DOM globals, so they will not work in pure Node.js environments lacking browser APIs.

How do I import and use supportive-is predicates in a TypeScript project?

To use supportive-is predicates in a TypeScript project, import the specific functions like isPromise or isDate. Apply them as type guards to narrow object types, leveraging constructor-name semantics to accurately validate instances and handle edge cases like invalid dates.