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 / tests / fixtures / tree / children-of.ts
13 lines · 486 BRaw
1/**
2 * A rendered tree node's children as the element table built them, or
3 * none for a string, a null, or a childless element.
4 *
5 * @param node an element, a string child, or anything else
6 * @returns the children array, possibly empty
7 */
8export function childrenOf(node: unknown): readonly unknown[] {
9 const isElement = typeof node === 'object' && node !== null
10 const held: unknown = isElement ? Reflect.get(node, 'children') : null
11
12 return Array.isArray(held) ? held : []
13}