From harness-claude
Implements JavaScript Iterator pattern for custom data structures like trees, graphs, linked lists, enabling for...of iteration, generators, and lazy data pipelines.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Traverse a collection sequentially without exposing its internal structure
Implements GoF Iterator pattern with JavaScript Symbol.iterator and generators for traversing custom structures like linked lists/trees, lazy composable sequences, and async pagination.
Generates Iterator pattern for PHP 8.4 collections: iterator interface, concrete iterator, iterable collection, value objects, and unit tests. Use for sequential traversal without exposing internals.
Teaches ES6+ features like arrow functions, destructuring, async/await, promises, and functional patterns for refactoring legacy JavaScript and optimizing web apps.
Share bugs, ideas, or general feedback.
Traverse a collection sequentially without exposing its internal structure
for...ofnext() method returning { value, done }.[Symbol.iterator]() that returns an iterator.function*) for the cleanest iterator implementation.for...of to consume iterables.class Range {
constructor(start, end) {
this.start = start;
this.end = end;
}
[Symbol.iterator]() {
let current = this.start;
const end = this.end;
return {
next() {
return current <= end
? { value: current++, done: false }
: { value: undefined, done: true };
},
};
}
}
for (const n of new Range(1, 3)) {
console.log(n); // 1, 2, 3
}
*[Symbol.iterator]() { for (let i = this.start; i <= this.end; i++) yield i; }.JavaScript has a built-in iteration protocol. Any object with a [Symbol.iterator]() method is iterable and works with for...of, spread (...), destructuring, Array.from(), and Promise.all(). Generators (function*) are the simplest way to create custom iterators.
Trade-offs:
done: true) will hang for...of loops unless guardedWhen NOT to use:
https://patterns.dev/javascript/iterator-pattern