<commit_before>module.exports = {
    tokens: ['Token-Type', 'Access-Token', 'Client', 'Uid', 'Expiry',
        'token-type', 'access-token', 'client', 'uid', 'expiry'],

    request: function (req, token) {
        var headers = {},
            tokens = token.split(';');

        var auth =  this.options.deviseAuth || this.options.auth;
        auth.tokens.forEach(function (tokenName, index) {
            if (tokens[index]) {
                headers[tokenName] = tokens[index];
            }
        });
        
        this.options.http._setHeaders.call(this, req, headers);
    },
    
    response: function (res) {
        var token = [],
            headers = this.options.http._getHeaders.call(this, res);
        
        if (headers['access-token'] || headers['Access-Token']) {
            var auth =  this.options.deviseAuth || this.options.auth;
            auth.tokens.forEach(function (tokenName) {
                if (headers[tokenName]) {
                    token.push(headers[tokenName]);
                }
            });
            
            return token.join(';');
        }
    }
};<commit_msg>Check if access-token more recent than last one<commit_after>module.exports = {
    tokens: ['Token-Type', 'Access-Token', 'Client', 'Uid', 'Expiry',
        'token-type', 'access-token', 'client', 'uid', 'expiry'],

    request: function (req, token) {
        var headers = {},
            tokens = token.split(';');

        var auth =  this.options.deviseAuth || this.options.auth;
        auth.tokens.forEach(function (tokenName, index) {
            if (tokens[index]) {
                headers[tokenName] = tokens[index];
            }
        });
        
        this.options.http._setHeaders.call(this, req, headers);
    },
    
    response: function (res) {
        var token = [],
            headers = this.options.http._getHeaders.call(this, res);
        
        if (headers['access-token'] || headers['Access-Token']) {
            var auth =  this.options.deviseAuth || this.options.auth;
            auth.tokens.forEach(function (tokenName) {
                if (headers[tokenName]) {
                    token.push(headers[tokenName]);
                }
            });
            
            // Check if access-token more recent than last one
            if (!this.token() || parseInt(token[4], 10) >= parseInt(this.token().split(';')[4], 10)) {
                return token.join(';');
            }
        }
    }
};
{'fraction_non_alphanumeric': 0.15437601296596434, 'fraction_numerical': 0.0024311183144246355, 'mean_word_length': 1.761744966442953, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4588360', 'n_tokens_mistral': 701, 'n_tokens_neox': 683, 'n_words': 133}