<commit_before>define(["jquery"],function($) {
    var jSend = function(config) {
        if( ! config.url ) throw new Error("No url supplied to jSend");

        var config = $.extend({
            throwError : true
        },config);

        var SUCCESS = 'success',
            FAIL    = 'fail',
            ERROR   = 'error',
            ERROR_STRING = 'The returned object was not in jSend format, use normal ajax to request it: ';

        var deferred = new $.Deferred(),
            self = this;

        $.ajax({
            url : config.url,
            type : config.type || "POST",
            data : config.data || null
        })
            .done(function(jsend) {
                if( ! jsend.status ) throw new Error(ERROR_STRING,jsend);

                switch(jsend.status) {
                    case SUCCESS:
                        deferred.resolve(jsend);
                        break;
                    case FAIL:
                        if( ! jsend.data ) throw new Error(ERROR_STRING,jsend);
                        deferred.reject(jsend);
                        if( cfg.throwError ) throw new Error('Some of the supplied data to the url: ' + config.submit_url + ' was incorrect. Failed with return: ' + jsend.data);
                        break;
                    case ERROR:
                        if( ! jsend.message ) throw new Error(ERROR_STRING,jsend);
                        deferred.reject(jsend);
                        if( cfg.throwError ) throw new Error('A server side error ocurred with message: ' + jsend.message);
                        break;
                    default:
                        throw new Error(ERROR_STRING,jsend);
                        break;
                }
            })
            .fail(function(data) {
                deferred.reject({
                    status : 'error',
                    message : 'The server responded with an error: ' + data.statusText
                });
                if(config.throwError) throw new Error("jSend got an http error with data: " + data.statusText);
            });

        return deferred.promise();
    }

	return jSend;
});<commit_msg>Requirejs and normal loading support<commit_after>(function(global) {
    var jSendPlugin = function($) {
        var jSend = function(config) {
            if( ! config.url ) throw new Error("No url supplied to jSend");

            var config = $.extend({
                throwError : true
            },config);

            var SUCCESS = 'success',
                FAIL    = 'fail',
                ERROR   = 'error',
                ERROR_STRING = 'The returned object was not in jSend format, use normal ajax to request it: ';

            var deferred = new $.Deferred(),
                self = this;

            $.ajax({
                url : config.url,
                type : config.type || "POST",
                data : config.data || null
            })
                .done(function(jsend) {
                    if( ! jsend.status ) throw new Error(ERROR_STRING,jsend);

                    switch(jsend.status) {
                        case SUCCESS:
                            deferred.resolve(jsend);
                            break;
                        case FAIL:
                            if( ! jsend.data ) throw new Error(ERROR_STRING,jsend);
                            deferred.reject(jsend);
                            if( cfg.throwError ) throw new Error('Some of the supplied data to the url: ' + config.submit_url + ' was incorrect. Failed with return: ' + jsend.data);
                            break;
                        case ERROR:
                            if( ! jsend.message ) throw new Error(ERROR_STRING,jsend);
                            deferred.reject(jsend);
                            if( cfg.throwError ) throw new Error('A server side error ocurred with message: ' + jsend.message);
                            break;
                        default:
                            throw new Error(ERROR_STRING,jsend);
                            break;
                    }
                })
                .fail(function(data) {
                    deferred.reject({
                        status : 'error',
                        message : 'The server responded with an error: ' + data.statusText
                    });
                    if(config.throwError) throw new Error("jSend got an http error with data: " + data.statusText);
                });

            return deferred.promise();
        }

    	return jSend;
    };

    if(typeof(define) === 'function' && define.amd) {
        define(["jquery"],jSendPlugin);
    } else {
        if(! global.jQuery) throw new Error("The jSend plugin require jQuery in the global namespace");
        jSendPlugin(global.jQuery);
    }
})(this);
{'fraction_non_alphanumeric': 0.09730848861283643, 'fraction_numerical': 0.0, 'mean_word_length': 1.2079524680073126, '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': '1704003', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1120, 'n_words': 323}