spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / hooks / count-of / count-of.ts
10 lines · 347 BRaw
1/**
2 * How many items of a list pass a test, without the intermediate array a
3 * filter would build.
4 *
5 * @param items the list
6 * @param passes the test
7 * @returns the number of passing items
8 */
9export const countOf = <T>(items: readonly T[], passes: (item: T) => boolean) =>
10 items.reduce((total, item) => total + (passes(item) ? 1 : 0), 0)