<commit_before>
/* Initializes module */
angular.module("ngHTTPPoll",[])
    .service("$httpoll",pollingService)

/* Polling service */

function pollingService($http, $timeout, $q) {

    var timeoutIdCounter = 1;
    var timeoutStatuses = {};
    var userDefaults = {};

    var HTTP_METHODS = {
        delete: {body: false},
        get: {body: false},
        jsonp: {body: false},
        patch: {body: true},
        post: {body: true},
        put: {body: true}
    };

    var POLLING_DEFAULTS = {
        retries: 50,
        delay: 100,
        retryOnError: true,
        timeout: false,
        successRange: [200, 201],
        errorRange: [400, 599],
        until: null
    }

    /* polls an API based on settings */
    var poller = function (config, state) {
        config = getConfig(config);
        state = state || {
            retryCount: 0
        };

        // allows overriding of the $http service, useful for testing
        var httpProvider = poller.provider || $http;

        if (config.timeout && !state.timeoutId) {
            timeoutIdCounter ++;
            state.timeoutId = timeoutIdCounter;
            $timeout(function(){
                timeoutStatuses[state.timeoutId] = true;
            }, config.timeout);
        }

        return httpProvider(config)
            .then(pollResponse, pollResponse)

        function pollResponse(response){

            var actions = {
                // apply default `until` logic
                pass: function() {
                    return defaultUntil(response, config, state)
                },
                // overrides config for subsequent requests
                reConfig: function (overrideConfig) {
                    return config = getConfig(config, overrideConfig);
                }
            }

            try {
                var untilFunc = config.until || defaultUntil;
                // deep-copy config prevents overriding config values
                var untilConfig = angular.copy(config);
                if (untilFunc(response, config, state, actions)) {
                    return response;
                } else {
                    state.retryCount += 1;
                    return $timeout(function(){
                        if (timeoutStatuses[state.timeoutId]) {
                            return $q.reject("Polling timed out")
                        }<commit_msg>actually uses untilconfig<commit_after>
/* Initializes module */
angular.module("ngHTTPPoll",[])
    .service("$httpoll",pollingService)

/* Polling service */

function pollingService($http, $timeout, $q) {

    var timeoutIdCounter = 1;
    var timeoutStatuses = {};
    var userDefaults = {};

    var HTTP_METHODS = {
        delete: {body: false},
        get: {body: false},
        jsonp: {body: false},
        patch: {body: true},
        post: {body: true},
        put: {body: true}
    };

    var POLLING_DEFAULTS = {
        retries: 50,
        delay: 100,
        retryOnError: true,
        timeout: false,
        successRange: [200, 201],
        errorRange: [400, 599],
        until: null
    }

    /* polls an API based on settings */
    var poller = function (config, state) {
        config = getConfig(config);
        state = state || {
            retryCount: 0
        };

        // allows overriding of the $http service, useful for testing
        var httpProvider = poller.provider || $http;

        if (config.timeout && !state.timeoutId) {
            timeoutIdCounter ++;
            state.timeoutId = timeoutIdCounter;
            $timeout(function(){
                timeoutStatuses[state.timeoutId] = true;
            }, config.timeout);
        }

        return httpProvider(config)
            .then(pollResponse, pollResponse)

        function pollResponse(response){

            var actions = {
                // apply default `until` logic
                pass: function() {
                    return defaultUntil(response, config, state)
                },
                // overrides config for subsequent requests
                reConfig: function (overrideConfig) {
                    return config = getConfig(config, overrideConfig);
                }
            }

            try {
                var untilFunc = config.until || defaultUntil;
                // deep-copy config prevents overriding config values
                var untilConfig = angular.copy(config);
                if (untilFunc(response, untilConfig, state, actions)) {
                    return response;
                } else {
                    state.retryCount += 1;
                    return $timeout(function(){
                        if (timeoutStatuses[state.timeoutId]) {
                            return $q.reject("Polling timed out")
                        }
{'fraction_non_alphanumeric': 0.10143421326127625, 'fraction_numerical': 0.008314279775514447, 'mean_word_length': 1.5393139841688654, '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': '3237320', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1161, 'n_words': 318}