import { validateFont } from './helpers/validate' ; import { GenericFont } from './types' ; export const createFont = < A extends GenericFont > ( font ) : A => { if ( process . env . NODE_ENV === 'development' ) { validateFont ( font ) ; } const sizeKeys = Object . keys ( font . size ) ; for ( const key in font ) { if ( key === 'size' || key === 'family' ) continue ; const section = font [ key ] ; const keys = Object . keys ( section ) ; let fillVal = section [ keys [ 0 ] ] ; for ( const sKey of sizeKeys ) { if ( ! ( sKey in section ) ) { section [ sKey ] = fillVal ; } else { fillVal = section [ sKey ] ; } } } return Object . freeze ( font ) ; } ;