{"size": 1333, "ext": "js", "max_stars_repo_path": "string-to-ms.js", "max_stars_repo_name": "tpkn/string-to-ms", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "string-to-ms.js", "max_issues_repo_name": "tpkn/string-to-ms", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "string-to-ms.js", "max_forks_repo_name": "tpkn/string-to-ms", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.137254902, "max_line_length": 107, "alphanum_fraction": 0.4471117779}
/*!
 * String To Milliseconds, http://tpkn.me/
 */

function stringToMs(str){
   let summ = 0, time, type, value;
   let time_list = ('' + str).split(' ').filter(v => v != '' && /^(\d{1,}\.)?\d{1,}([wdhms])?$/i.test(v));

   for(let i = 0, len = time_list.length; i < len; i++){
      time = time_list[i];
      type = time.match(/[wdhms]$/i);

      if(type){
         value = Number(time.replace(type[0], ''));

         switch(type[0].toLowerCase()){
            case 'w':
               summ += value * 604800000;
            break;
            case 'd':
               summ += value * 86400000;
            break;
            case 'h':
               summ += value * 3600000;
            break;
            case 'm':
               summ += value * 60000;
            break;
            case 's':
               summ += value * 1000;
            break;
         }
      }else if(!isNaN(parseFloat(time)) && isFinite(time)){
         summ += parseFloat(time);
      }
   }
   return summ;
}

if(typeof module !== 'undefined' && typeof module.exports !== 'undefined'){
   module.exports = stringToMs;
}else{
   if(typeof define === 'function' && define.amd){
      define([], function(){
         return stringToMs;
      });
   }else{
      window.stringToMs = stringToMs;
   }
}
