skills/design-patterns/behaviorals/pattern-iterator/SKILL.md
Teaches and applies the Iterator behavioral design pattern — providing sequential access to elements of a collection without exposing its internal representation. Trigger: When traversing complex data structures or building custom collection iterators.
npx skillsauth add johnnystefan/test-saas-business pattern-iteratorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation (list, stack, tree, etc.).
next() element and checking if there are hasMore() items.createIterator().interface MyIterator<T> {
next(): T;
hasNext(): boolean;
}
class AlphabeticalIterator implements MyIterator<string> {
private position: number = 0;
constructor(private collection: string[]) {}
next(): string {
return this.collection[this.position++];
}
hasNext(): boolean {
return this.position < this.collection.length;
}
}
interface IterableCollection {
getIterator(): MyIterator<string>;
}
tools
Zustand 5 state management patterns. Trigger: When implementing client-side state with Zustand (stores, selectors, persist middleware, slices).
databases
Zod 4 schema validation patterns. Trigger: When creating or updating Zod v4 schemas for validation/parsing (forms, request payloads, adapters), including v3 -> v4 migration patterns.
development
Vitest unit testing patterns with React Testing Library. Trigger: When writing unit tests for React components, hooks, or utilities.
tools
Vite 8 (Rolldown-powered) build tool configuration, plugin API, SSR, and migration guide. Trigger: When working with vite.config.ts, Vite plugins, building libraries, or SSR apps with Vite.