<commit_before>"use strict";


var
  _ = require('lodash'),
  env = process.env,
  url = require('url'),
  validUrl = require('valid-url');

var nodeMode = env.NODE_ENV;
var contexts = [];

function sconf(conf, development, test, production){
  if(_.isString(conf)){
    var prefix = contexts.join('_');
    var val = env[prefix ? prefix+'_'+conf : conf];
    var extra;
    switch(nodeMode){
      case 'development':
        extra = development;
        break;
      case 'test':
        extra = test;
        break;
      case 'production':
        extra = production
        break;
    }
    val = val || extra || development || test || production;
    
    if(_.isString(val) && validUrl.isUri(val)){
      return url.parse(val);
    }else{
      return val;
    }
  } else{
    if(contexts.length){
      contexts.pop();
    }
    return conf;
  }
}

sconf.prefix = function(prefix){<commit_msg>Added support for booleans and empty strings<commit_after>"use strict";


var
  _ = require('lodash'),
  env = process.env,
  url = require('url'),
  validUrl = require('valid-url');

var nodeMode = env.NODE_ENV;
var contexts = [];

function sconf(conf, development, test, production){
  if(_.isString(conf)){
    var prefix = contexts.join('_');
    var val = env[prefix ? prefix+'_'+conf : conf];
    var extra;
    switch(nodeMode){
      case 'development':
        extra = development;
        break;
      case 'test':
        extra = test;
        break;
      case 'production':
        extra = production
        break;
    }
    val = val || extra || development || test || production || '';
    
    if(_.isString(val) && validUrl.isUri(val)){
      return url.parse(val);
    }else{
      switch(val){
        case 'true': return true;
        case 'false': return false;
        default: return val;
      }
    }
  } else{
    if(contexts.length){
      contexts.pop();
    }
    return conf;
  }
}

sconf.prefix = function(prefix){
{'fraction_non_alphanumeric': 0.14637904468412943, 'fraction_numerical': 0.0, 'mean_word_length': 2.4055944055944054, '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': '1703764', 'n_tokens_mistral': 615, 'n_tokens_neox': 604, 'n_words': 149}