<commit_before>'use strict';

var es = require('event-stream');
var fs = require('fs');
var knox = require('knox');
var gutil = require('gulp-util');

module.exports = function (aws, options) {
  options = options || {};
  
  if (!options.delay) { options.delay = 0; }
  
  var client = knox.createClient(aws);
  var waitTime = 0;
  var regex = /\.([a-z]{2,4})\.gz$/i;

  return es.mapSync(function (file, cb) {
      var isFile = fs.lstatSync(file.path).isFile();

      // Verify this is a file and it doesn't matche our filter
      if (!isFile) { return false; }

      var uploadPath = file.path.replace(file.base, options.uploadPath || '');

      var headers = { 'x-amz-acl': 'public-read' };
      if (options.headers) {
          for (var key in options.headers) {
              headers[key] = options.headers[key];
          }
      }

      var matches;
      if (options.gzippedOnly && !/\.gz$/gi.test(file.path)) { 
        // If we have gzip enabled, ignore non-gzipped files
        return false; 
      } else if (options.gzippedOnly && (matches = regex.exec(file.path))) {
        // Handle uploading of gzipped files, set headers + rename extension

        var suffix = matches[1];
        var encoding = 'plain';
        
        switch (suffix) {
            case 'js':
                suffix = 'javascript';
                encoding = 'text';
                break;

            case 'css':
            case 'html': 
                encoding = 'text';
                break;        

            case 'jpg':
                encode = 'image';
                suffix = 'jpeg';
                break;

            case 'png':
            case 'bmp':
            case 'gif':
                encoding = 'image';
                break;

            default:<commit_msg>fix(index): Fix some comments + better variable names<commit_after>'use strict';

var es = require('event-stream');
var fs = require('fs');
var knox = require('knox');
var gutil = require('gulp-util');

module.exports = function (aws, options) {
  options = options || {};
  
  if (!options.delay) { options.delay = 0; }
  
  var client = knox.createClient(aws);
  var waitTime = 0;
  var regexGzip = /\.([a-z]{2,4})\.gz$/i;

  return es.mapSync(function (file, cb) {
      var isFile = fs.lstatSync(file.path).isFile();

      // Verify this is a file
      if (!isFile) { return false; }

      var uploadPath = file.path.replace(file.base, options.uploadPath || '');

      var headers = { 'x-amz-acl': 'public-read' };
      if (options.headers) {
          for (var key in options.headers) {
              headers[key] = options.headers[key];
          }
      }

      var matches;
      if (options.gzippedOnly && !regexGzip.test(file.path)) { 
        // If we have gzip mode enabled, ignore non-gzipped files
        return false; 
      } else if (options.gzippedOnly && (matches = regexGzip.exec(file.path))) {
        // Handle uploading of gzipped files, set headers + rename extension

        var suffix = matches[1];
        var encoding = 'plain';
        
        switch (suffix) {
            case 'js':
                suffix = 'javascript';
                encoding = 'text';
                break;

            case 'css':
            case 'html': 
                encoding = 'text';
                break;        

            case 'jpg':
                encode = 'image';
                suffix = 'jpeg';
                break;

            case 'png':
            case 'bmp':
            case 'gif':
                encoding = 'image';
                break;

            default:
{'fraction_non_alphanumeric': 0.13537604456824512, 'fraction_numerical': 0.002785515320334262, 'mean_word_length': 1.6423841059602649, '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': '7257737', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1009, 'n_words': 280}