tsentials/array

Community

Guarantee non-empty arrays with type-safe helpers

Authorsenrecep
Version1.0.0
Installs0

System Documentation

What problem does it solve?

It solves the problem of unsafe array access by providing a type-safe way to represent arrays that are guaranteed to contain at least one element.

Core Features & Use Cases

  • NonEmptyArray<T> type: Represents Array<T> with the invariant that index 0 exists, eliminating undefined checks for operations like head and last.
  • Runtime narrowing and conversions: Use asNonEmptyArray to convert a plain array into a safe Option-like outcome, and isNonEmpty as a type guard.
  • Invariant-preserving operations: Use utilities such as reverse that preserve the non-empty guarantee, while transform/utility functions like filter intentionally return arrays that may become empty.
  • Use cases: Validating user input lists, processing pipelines that require at least one item, and building deterministic business rules where empty collections are invalid states.

Quick Start

Use the NonEmptyArray helpers to enforce that your function inputs must contain at least one element, and convert from a possibly-empty array with asNonEmptyArray when needed.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: tsentials/array
Download link: https://github.com/senrecep/tsentials/archive/main.zip#tsentials-array

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.