single-or-array-pattern

Installation
SKILL.md

Single-or-Array Pattern

Accept both single items and arrays, normalize at the top, process uniformly.

Quick Reference

function create(itemOrItems: T | T[]): Promise<Result<void, E>> {
	const items = Array.isArray(itemOrItems) ? itemOrItems : [itemOrItems];
	// ... implementation works on items array
}

The Structure

  1. Accept T | T[] as the parameter type
  2. Normalize with Array.isArray() at the top of the function
  3. All logic works against the array : one code path
Installs
64
GitHub Stars
4.6K
First Seen
Jan 20, 2026
single-or-array-pattern — epicenterhq/epicenter