<commit_before>'use strict';

var React = require('react');
var FontAwesome = require('react-native-vector-icons/FontAwesome');
var Foundation = require('react-native-vector-icons/Foundation');
var Ionicons = require('react-native-vector-icons/Ionicons');
var MaterialIcons = require('react-native-vector-icons/MaterialIcons');
var Zocial = require('react-native-vector-icons/Zocial');
var SimpleLineIcons = require('react-native-vector-icons/SimpleLineIcons');

var iconSetMap = {
  fontawesome: FontAwesome,
  foundation: Foundation,
  ion: Ionicons,
  material: MaterialIcons,
  zocial: Zocial,
  simpleline: SimpleLineIcons
};

// This is a composition is a drop in replacement for users migrating from the
// react-native-icons module. Please don't use this component for new apps/views.
var Icon = React.createClass({
  propTypes: {
    name: React.PropTypes.string.isRequired,
    size: React.PropTypes.number,
    color: React.PropTypes.string,
  },
  _root: (null:?Object),

  setNativeProps: function(nativeProps) {
    if (this._root == null) {
      throw new Error("Ref must have been set before calling setNativeProps");
    }
    this._root.setNativeProps(nativeProps);
  },

  render: function() {
    var { name, ...props } = this.props;

    var nameParts = name.split('|');
    var setName = nameParts[0];
    props.name = nameParts[1];
    props.ref = (component) => this._root = component;

    var IconSet = iconSetMap[setName];
    if(!IconSet) {
      throw new Error('Invalid icon set "' + setName + '"');
    }
    return (<IconSet allowFontScaling={false} {...props} />);
  }
});

module.exports = Icon;<commit_msg>Refactor RNIMigration component to ES2016<commit_after>import React from 'react';
import FontAwesome from 'react-native-vector-icons/FontAwesome';
import Foundation from 'react-native-vector-icons/Foundation';
import Ionicons from 'react-native-vector-icons/Ionicons';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import Zocial from 'react-native-vector-icons/Zocial';
import SimpleLineIcons from 'react-native-vector-icons/SimpleLineIcons';

const ICON_SET_MAP = {
  fontawesome: FontAwesome,
  foundation: Foundation,
  ion: Ionicons,
  material: MaterialIcons,
  zocial: Zocial,
  simpleline: SimpleLineIcons,
};

// This is a composition is a drop in replacement for users migrating from the
// react-native-icons module. Please don't use this component for new apps/views.
export default class Icon extends React.Component {
  static propTypes = {
    name: React.PropTypes.string.isRequired,
    size: React.PropTypes.number,
    color: React.PropTypes.string,
  };

  setNativeProps(nativeProps) {
    if (this.iconRef) {
      this.iconRef.setNativeProps(nativeProps);
    }
  }

  iconRef = null;

  handleComponentRef = (ref) => {
    this.iconRef = ref;
  };

  render() {
    const nameParts = this.props.name.split('|');
    const setName = nameParts[0];
    const name = nameParts[1];

    const IconSet = ICON_SET_MAP[setName];
    if (!IconSet) {
      throw new Error(`Invalid icon set "${setName}"`);
    }

    return (
      <IconSet
        allowFontScaling={false}
        ref={this.handleComponentRef}
        {...this.props}
        name={name}
      />
    );
  }
}
{'fraction_non_alphanumeric': 0.12622850122850124, 'fraction_numerical': 0.002457002457002457, 'mean_word_length': 3.775659824046921, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7610019', 'n_tokens_mistral': 1021, 'n_tokens_neox': 997, 'n_words': 243}