<commit_before>var Globalize = require("globalize");
var mixins = {};

Object.getOwnPropertyNames(Globalize).forEach(function(fn) {
    if (fn.indexOf("format") === 0) {
        var fnString = Globalize[fn].toString();
        var argString = fnString.substr(fnString.indexOf("(")+1, fnString.indexOf(")")-(fnString.indexOf("(")+1)).trim();
        var argArray = argString.split(", ");

        (function(currentFn, currentArgs) {
            var formatter = function(nextProps) {
                var componentProps = nextProps || this.props;
                var propArgs = currentArgs.map(function(element) {
                        return componentProps[element.replace(/(\s\/\*|\*\/)/,"").trim()];
                    });

                Globalize.locale( componentProps["locale"] );
                this.setState({
                    formattedValue: Globalize[currentFn].apply(Globalize, propArgs)
                });
            };

            mixins[currentFn] = {
                componentWillMount: formatter,
                componentWillReceiveProps: formatter
            };
        })(fn, argArray);
    }
});
module.exports = mixins;<commit_msg>Support either global or local locale<commit_after>var Globalize = require("globalize");
var mixins = {};

Object.getOwnPropertyNames(Globalize).forEach(function(fn) {
    if (fn.indexOf("format") === 0) {
        var fnString = Globalize[fn].toString();
        var argString = fnString.substr(fnString.indexOf("(")+1, fnString.indexOf(")")-(fnString.indexOf("(")+1)).trim();
        var argArray = argString.split(", ");

        (function(currentFn, currentArgs) {
            var formatter = function(nextProps) {
                var instance = Globalize;
                var componentProps = nextProps || this.props;
                var propArgs = currentArgs.map(function(element) {
                        return componentProps[element.replace(/(\s\/\*|\*\/)/,"").trim()];
                    });

                if (componentProps["locale"]) {
                  instance = Globalize(componentProps["locale"]);
                }
                this.setState({
                    formattedValue: instance[currentFn].apply(instance, propArgs)
                });
            };

            mixins[currentFn] = {
                componentWillMount: formatter,
                componentWillReceiveProps: formatter
            };
        })(fn, argArray);
    }
});

module.exports = mixins;
{'fraction_non_alphanumeric': 0.1447742984953233, 'fraction_numerical': 0.0024400162667751117, 'mean_word_length': 2.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5459820', 'n_tokens_mistral': 653, 'n_tokens_neox': 620, 'n_words': 105}