<commit_before>exports = module.exports = function(IoC, logger) {
  var uri = require('url');
  
  return Promise.resolve()
    .then(function discoverService() {
      var components = IoC.components('http://i.bixbyjs.org/http/session/StoreServiceDiscoverFunc');
  
      return Promise.all(components.map(function(c) { return c.create(); } ))
        .then(function(funcs) {
          return new Promise(function(resolve, reject) {
            
            // Iterate over each of the `discover` functions, attempting to
            // locate a service capable of storing HTTP sessions.
            (function iter(i) {
              var func = funcs[i];
              if (!func) {
                // Reject with `ENOTFOUND`, causing a jump to the next catch
                // function.  This function will attempt to create a suitable
                // store based on the host environment.
                return reject('ENOTFOUND');
              }
          
              logger.debug('Discovering HTTP session service via ' + components[i].a['@type']);
              func(function(err, records) {
                if (err && err.code == 'ENOTFOUND') {
                  // Unable to locate a service of this particular type.
                  // Continue discovery using remaining supported service types.
                  return iter(i + 1);
                } else if (err) {
                  return reject(err);
                }
                
                if (!records) { return iter(i + 1); }
                return resolve(records);
              });
            })(0);
            
          });
        });
    })
    .then(function createStore(records) {
      
      
      /*
      if (!records) {
        // TODO: Only when NODE_ENV is set to development
        return IoC.create('./store/memory');
      }
      */
      
      var record = records[0];
      var url = uri.parse(record.url);
      var protocol = url.protocol.slice(0, -1);
      
      
      var components = IoC.components('http://i.bixbyjs.org/http/session/Store')
        , component, i, len;
      
      for (i = 0, len = components.length; i < len; ++i) {
        component = components[i];
        if (component.a['@protocol'] == protocol) {
          return component.create({ url: record.url });
        }
      }
    })
    .catch(function createDevelopmentStoreIfOK(err) {
      if (err !== 'ENOTFOUND') { throw err; }
      if (process.env.NODE_ENV !== 'development') {<commit_msg>Clean up session store creation.<commit_after>exports = module.exports = function(IoC, logger) {
  var uri = require('url');
  
  return Promise.resolve()
    .then(function discoverService() {
      var components = IoC.components('http://i.bixbyjs.org/http/session/StoreServiceDiscoverFunc');
  
      return Promise.all(components.map(function(c) { return c.create(); } ))
        .then(function(funcs) {
          return new Promise(function(resolve, reject) {
            
            // Iterate over each of the `discover` functions, attempting to
            // locate a service capable of storing HTTP sessions.
            (function iter(i) {
              var func = funcs[i];
              if (!func) {
                // Reject with `ENOTFOUND`, causing a jump to the next catch
                // function.  This function will attempt to create a suitable
                // store based on the host environment.
                return reject('ENOTFOUND');
              }
          
              logger.debug('Discovering HTTP session service via ' + components[i].a['@type']);
              func(function(err, records) {
                if (err && err.code == 'ENOTFOUND') {
                  // Unable to locate a service of this particular type.
                  // Continue discovery using remaining supported service types.
                  return iter(i + 1);
                } else if (err) {
                  return reject(err);
                }
                
                if (!records) { return iter(i + 1); }
                return resolve(records);
              });
            })(0);
            
          });
        });
    })
    .then(function createStore(records) {
      var components = IoC.components('http://i.bixbyjs.org/http/session/Store')
        , record = records[0]
        , url = uri.parse(record.url)
        , protocol = url.protocol.slice(0, -1)
        , component, i, len;
      
      for (i = 0, len = components.length; i < len; ++i) {
        component = components[i];
        if (component.a['@protocol'] == protocol) {
          return component.create({ url: record.url });
        }
      }
    })
    .catch(function createDevelopmentStoreIfOK(err) {
      if (err !== 'ENOTFOUND') { throw err; }
      if (process.env.NODE_ENV !== 'development') {
{'fraction_non_alphanumeric': 0.12146422628951747, 'fraction_numerical': 0.0029118136439267887, 'mean_word_length': 1.625, 'pattern_counts': {'":': 0, '<': 5, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1416280', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1247, 'n_words': 339}