"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

/**
 * 
 * @param {string} key 
 * @param {string|number|boolean} defaultValue 
 * @param {('string'|'number'|'boolean')} type
 */
const env = (key, defaultValue = null, type = 'string') => {
  let value = process.env[key];

  if (type === 'number') {
    let numberValue = parseInt(value, 10);
    return numberValue.toString() === value ? numberValue : defaultValue;
  }

  if (type === 'boolean') {
    let boolValue = (value + '').toLowerCase();
    if (boolValue === 'true') return true;else if (boolValue === 'false') return false;else return defaultValue;
  }

  return value ? value : defaultValue;
};

var _default = env;
exports.default = _default;