( props: Lookup, transform: (value: any, key: string) => any = noopTransform )
| 70 | * truthy. |
| 71 | */ |
| 72 | export const getDefaultProps = <T extends Lookup>( |
| 73 | props: Lookup, |
| 74 | transform: (value: any, key: string) => any = noopTransform |
| 75 | ): T => { |
| 76 | let keys: readonly string[] = DEFAULT_PROPS |
| 77 | if (props.default && props.default !== true) { |
| 78 | props = props.default |
| 79 | keys = Object.keys(props) |
| 80 | } |
| 81 | const defaults: any = {} |
| 82 | for (const key of keys) { |
| 83 | const value = transform(props[key], key) |
| 84 | if (!is.und(value)) { |
| 85 | defaults[key] = value |
| 86 | } |
| 87 | } |
| 88 | return defaults |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * These props are implicitly used as defaults when defined in a |
no test coverage detected
searching dependent graphs…