Files
SnowLuma/.pnpm-store/v11/files/ff/b70be43a05ea4c2144214d4f21f0bd71fb2c0c8a4f4d2b26a5f9ef9b083c8df703d7fd1a579bc6a8a9c0a1eb9bb931b5f01b496147dee625a914d008d08857
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

18 lines
526 B
Plaintext

//#region src/jsx/children.ts
const toArray = (children) => Array.isArray(children) ? children : [children];
const Children = {
map: (children, fn) => toArray(children).map(fn),
forEach: (children, fn) => {
toArray(children).forEach(fn);
},
count: (children) => toArray(children).length,
only: (_children) => {
const children = toArray(_children);
if (children.length !== 1) throw new Error("Children.only() expects only one child");
return children[0];
},
toArray
};
//#endregion
export { Children, toArray };