All files / src/utils normalization.js

45.45% Statements 10/22
50% Branches 1/2
50% Functions 1/2
45.45% Lines 10/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 281x 1x 1x       1x 1x 1x 1x   1x 1x   1x                          
// src/utils/normalization.js
export function normalizeProps(props) {
    if (!props || typeof props !== 'object') {
        return {};
    }
 
    // Filter out key and ref from props (they're handled separately)
    const normalizedProps = { ...props };
    delete normalizedProps.key;
    delete normalizedProps.ref;
 
    return normalizedProps;
}
 
export function flattenChildren(children) {
    const flattened = [];
 
    for (const child of children) {
        if (Array.isArray(child)) {
            flattened.push(...flattenChildren(child));
        } else if (child !== null && child !== undefined && child !== false) {
            flattened.push(child);
        }
    }
 
    return flattened;
}