<commit_before>define(['jquery'], function(jQuery) {

    var ajax = jQuery.ajax,
        requestQueue = [],
        requestPending = false;

    function sendRequest(options, promise, trigger) {
        var complete, error, options, params, success, that = this;

        if (trigger !== false) trigger = true;
        if (trigger) requestPending = true;

        success = options.success;
        error = options.error;
        complete = options.complete;

        params = {
            complete: function(xhr, status) {
                if (complete) complete.apply(that, arguments);
                if (trigger) dequeueRequest();
            },
            success: function() {
                if (success) success.apply(that, arguments);
                promise.resolveWith(this, arguments);
            },
            error: function() {
                if (error) error.apply(this, arguments);
                promise.rejectWith(this, arguments);
            }
        };

        ajax(jQuery.extend({}, options, params));
    };

    function dequeueRequest() {
        var args, options, promise;
        if ((args = requestQueue.shift())) {
            options = args[0], promise = args[1];
            sendRequest(options, promise);
        } else {
            requestPending = false;
        }
    };

    function queueRequest(options) {
        var promise, type, queue;
        promise = $.Deferred();
        type = (options.type || 'get').toLowerCase();<commit_msg>Simplify sendRequest promise augmentation in jquery-ajax-queue<commit_after>define(['jquery'], function(jQuery) {

    var ajax = jQuery.ajax,
        requestQueue = [],
        requestPending = false;

    function sendRequest(options, promise, trigger) {
        var complete, error, options, params, success, that = this;

        if (trigger !== false) trigger = true;
        if (trigger) requestPending = true;

        promise
            .done(options.success)
            .fail(options.error)
            .always(options.complete);

        params = {
            complete: function() {
                if (trigger) dequeueRequest();
            },
            success: function() {
                promise.resolveWith(this, arguments);
            },
            error: function() {
                promise.rejectWith(this, arguments);
            }
        };

        ajax(jQuery.extend({}, options, params));
    };

    function dequeueRequest() {
        var args, options, promise;
        if ((args = requestQueue.shift())) {
            options = args[0], promise = args[1];
            sendRequest(options, promise);
        } else {
            requestPending = false;
        }
    };

    function queueRequest(options) {
        var promise, type, queue;
        promise = $.Deferred();
        type = (options.type || 'get').toLowerCase();
{'fraction_non_alphanumeric': 0.12144612144612145, 'fraction_numerical': 0.001404001404001404, 'mean_word_length': 1.8217821782178218, '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': '4134291', 'n_tokens_mistral': 721, 'n_tokens_neox': 704, 'n_words': 177}