<commit_before>import React from 'react'
import niceStyles from 'motion-nice-styles'
import { StyleSheet, css } from 'motion-aphrodite'

export default function Style(ComposedComponent) {
  class StyledComponent extends ComposedComponent {
    constructor() {
      super(...arguments)

      if (this.style) {
        const styles = Object.assign({}, this.style)

        for (let style in styles)
          niceStyles(styles[style])

        this.stylesheet = StyleSheet.create(styles)
      }
    }

    render() {
      console.log('testing 124')

      return this.stylesheet ?
        this.styleAll.call(this, super.render()) :
        super.render()
    }

    styleAll(children) {
      if (!children || !Array.isArray(children) && !children.props)
        return children

      const count = React.Children.count(children)
      const styler = this.styleOne.bind(this)

      console.log(children)

      if (Array.isArray(children))
        return children.map(styler)
      if (count > 1)
        return React.Children.map(children, styler)
      else
        return styler(children)
    }

    styleOne(child) {
      if (!child || !React.isValidElement(child))
        return child

      let cloneProps = {}

      if (this.style) {
        // <View /> or <tag /> styles
        const name = child.type && (child.type.name || child.type)
        // <name $tag /> styles
        const tagged = Object.keys(child.props)
          .filter(key => key[0] == '$') // only $props
          .map(key => key.slice(1)) // remove $

        const styles =  [name, ...tagged]
          .map(i => this.stylesheet[i])
          .reduce((acc, cur) => acc.concat(cur || []), [])

        cloneProps.className = css(...styles)
      }

      if (child.props && child.props.children)
        cloneProps.children = this.styleAll(child.props.children)

      return React.cloneElement(child, cloneProps)
    }
  }

  return StyledComponent
}
<commit_msg>:memo: cleanup structure of style<commit_after>import React from 'react'
import niceStyles from 'motion-nice-styles'
import { StyleSheet, css } from 'motion-aphrodite'

export default function Style(ComposedComponent) {
  class StyledComponent extends ComposedComponent {
    constructor() {
      super(...arguments)

      if (this.style) {
        const styles = Object.assign({}, this.style)

        for (let style in styles)
          niceStyles(styles[style])

        this.stylesheet = StyleSheet.create(styles)
      }
    }

    render() {
      return this.stylesheet ?
        this.styleAll.call(this, super.render()) :
        super.render()
    }

    styleAll(children) {
      if (!children || !Array.isArray(children) && !children.props || !this.style)
        return children

      const count = React.Children.count(children)
      const styler = this.styleOne.bind(this)

      if (Array.isArray(children))
        return children.map(styler)
      if (count > 1)
        return React.Children.map(children, styler)
      else
        return styler(children)
    }

    styleOne(child) {
      if (!child || !React.isValidElement(child))
        return child

      // <View /> + <tag /> keys
      const name = child.type && (child.type.name || child.type)

      // <name $tag /> keys
      const tagged = Object.keys(child.props)
        .filter(key => key[0] == '$' && child.props[key] === true) // only $props
        .map(key => key.slice(1)) // remove $

      // styles
      const styles = [name, ...tagged]
        .map(i => this.stylesheet[i])
        .reduce((acc, cur) => acc.concat(cur || []), [])

      let cloneProps = {}

      if (styles.length)
        cloneProps.className = css(...styles)

      if (child.props && child.props.children)
        cloneProps.children = this.styleAll(child.props.children)

      return React.cloneElement(child, cloneProps)
    }
  }

  return StyledComponent
}

{'fraction_non_alphanumeric': 0.13564993564993566, 'fraction_numerical': 0.0023166023166023165, 'mean_word_length': 2.298811544991511, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, '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': '6245602', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1125, 'n_words': 254}