mirror of
https://github.com/anthropics/claude-code.git
synced 2026-09-14 19:48:39 +08:00
18be13be81
Squash merge of 4 commits
14 lines
486 B
TypeScript
14 lines
486 B
TypeScript
/**
|
|
* A rendered tree node's children as the element table built them, or
|
|
* none for a string, a null, or a childless element.
|
|
*
|
|
* @param node an element, a string child, or anything else
|
|
* @returns the children array, possibly empty
|
|
*/
|
|
export function childrenOf(node: unknown): readonly unknown[] {
|
|
const isElement = typeof node === 'object' && node !== null
|
|
const held: unknown = isElement ? Reflect.get(node, 'children') : null
|
|
|
|
return Array.isArray(held) ? held : []
|
|
}
|