import { StyleObject } from './Rule' ; import { Indexable } from './utils/types' ; const _uppercasePattern = /([A-Z])/g ; const msPattern = /^ms-/ ; const cache = { } ; function hyphenateStyleName ( str ) { if ( ! cache . hasOwnProperty ( str ) ) { cache [ str ] = str . replace ( _uppercasePattern , '-$1' ) . replace ( msPattern , '-ms-' ) . toLowerCase ( ) ; } return cache [ str ] ; } param style returns export default function styleToString ( style ) { let result = '' ; for ( const prop in style ) { if ( style . hasOwnProperty ( prop ) ) { const value = style [ prop ] ; if ( Array . isArray ( value ) ) { for ( const styleValue of value ) { result += hyphenateStyleName ( prop ) + ':' + styleValue + ';' ; } } else { result += hyphenateStyleName ( prop ) + ':' + value + ';' ; } } } return result || null ; }