Sha256: 46fb00b0ca4275b2eaac03cb8a9a6ef49f4598581f361775c54cff9c42b7b840
Contents?: true
Size: 575 Bytes
Versions: 12
Compression:
Stored size: 575 Bytes
Contents
import { toChildArray } from 'preact'; const mapFn = (children, fn) => { if (children == null) return null; return toChildArray(toChildArray(children).map(fn)); }; // This API is completely unnecessary for Preact, so it's basically passthrough. export const Children = { map: mapFn, forEach: mapFn, count(children) { return children ? toChildArray(children).length : 0; }, only(children) { const normalized = toChildArray(children); if (normalized.length !== 1) throw 'Children.only'; return normalized[0]; }, toArray: toChildArray };
Version data entries
12 entries across 12 versions & 1 rubygems