UNPKG

wix-storybook-utils

Version:

Utilities for automated component documentation within Storybook

22 lines (18 loc) 564 B
import { Descriptor } from './typings'; const isNested = (item: Descriptor) => item.type === 'object'; export const flatten = (methodsList: Descriptor[], name = '') => methodsList .filter(i => i && i.type) .reduce((list, item: Descriptor) => { if (isNested(item)) { list = list.concat( flatten(item.props, name ? `${name}.${item.name}` : item.name), ); } else { list.push({ ...item, ...(name ? { name: `${name}.${item.name}` } : {}), }); } return list; }, []);