<commit_before>/* @flow weak */
import hypenateStyleName from 'hyphenate-style-name'
import warning from './warning'

/**
 * generates a valid CSS string containing style
 *
 * @param {Object} style - object containing CSS declarations
 * @returns {string} valid CSS string with dash cased properties
 */
export default function cssifyObject(style) {
  return Object.keys(style).reduce((css, prop) => {
    // warn if invalid values are rendered
    warning(typeof style[prop] === 'string' || typeof style[prop] === 'number', 'An invalid value "' + style[prop] + '" has been used as "' + prop + '".')

    // prevents the semicolon after
    // the last rule declaration
    if (css.length > 0) {
      css += ';'
    }

    css += hypenateStyleName(prop) + ':' + style[prop]
    return css
  }, '')
}<commit_msg>filter undefined values to prevent false warnings<commit_after>/* @flow weak */
import hypenateStyleName from 'hyphenate-style-name'
import warning from './warning'

/**
 * generates a valid CSS string containing style
 *
 * @param {Object} style - object containing CSS declarations
 * @returns {string} valid CSS string with dash cased properties
 */
export default function cssifyObject(style) {
  return Object.keys(style).reduce((css, prop) => {
    const value = style[prop]

    // automatically remove undefined values
    if (value === undefined || (typeof value === 'string' && value.indexOf('undefined') > -1)) {
      return css
    }

    // warn if invalid values are rendered
    warning(typeof style[prop] === 'string' || typeof style[prop] === 'number', 'An invalid value "' + style[prop] + '" has been used as "' + prop + '".')

    // prevents the semicolon after
    // the last rule declaration
    if (css.length > 0) {
      css += ';'
    }

    css += hypenateStyleName(prop) + ':' + style[prop]
    return css
  }, '')
}
{'fraction_non_alphanumeric': 0.14093598708983324, 'fraction_numerical': 0.0016137708445400753, 'mean_word_length': 3.335664335664336, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '640572', 'n_tokens_mistral': 531, 'n_tokens_neox': 517, 'n_words': 181}